mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Cache result of parsing macro calls which don't use text subsitution (#5205)
This commit is contained in:
parent
b0f6d50b60
commit
0b1a05d10d
@ -55,9 +55,18 @@ MacroCallWidget.prototype.execute = function() {
|
|||||||
// Are we rendering to HTML?
|
// Are we rendering to HTML?
|
||||||
if(this.renderOutput === "text/html") {
|
if(this.renderOutput === "text/html") {
|
||||||
// If so we'll return the parsed macro
|
// If so we'll return the parsed macro
|
||||||
var parser = this.wiki.parseText(this.parseType,text,
|
// Check if we've already cached parsing this macro
|
||||||
{parseAsInline: !this.parseTreeNode.isBlock});
|
var parser;
|
||||||
parseTreeNodes = parser ? parser.tree : [];
|
if(variableInfo.srcVariable && variableInfo.srcVariable.parser) {
|
||||||
|
parser = variableInfo.srcVariable.parser;
|
||||||
|
} else {
|
||||||
|
parser = this.wiki.parseText(this.parseType,text,
|
||||||
|
{parseAsInline: !this.parseTreeNode.isBlock});
|
||||||
|
if(variableInfo.isCacheable && variableInfo.srcVariable) {
|
||||||
|
// variableInfo.srcVariable.parser = parser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var parseTreeNodes = parser ? parser.tree : [];
|
||||||
// Wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
|
// Wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
|
||||||
var attributes = {};
|
var attributes = {};
|
||||||
$tw.utils.each(variableInfo.params,function(param) {
|
$tw.utils.each(variableInfo.params,function(param) {
|
||||||
|
@ -113,7 +113,8 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
|||||||
// Check for the variable defined in the parent widget (or an ancestor in the prototype chain)
|
// Check for the variable defined in the parent widget (or an ancestor in the prototype chain)
|
||||||
if(parentWidget && name in parentWidget.variables) {
|
if(parentWidget && name in parentWidget.variables) {
|
||||||
var variable = parentWidget.variables[name],
|
var variable = parentWidget.variables[name],
|
||||||
value = variable.value,
|
originalValue = variable.value,
|
||||||
|
value = originalValue,
|
||||||
params = this.resolveVariableParameters(variable.params,actualParams);
|
params = this.resolveVariableParameters(variable.params,actualParams);
|
||||||
// Substitute any parameters specified in the definition
|
// Substitute any parameters specified in the definition
|
||||||
$tw.utils.each(params,function(param) {
|
$tw.utils.each(params,function(param) {
|
||||||
@ -125,7 +126,9 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
text: value,
|
text: value,
|
||||||
params: params
|
params: params,
|
||||||
|
srcVariable: variable,
|
||||||
|
isCacheable: originalValue === value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// If the variable doesn't exist in the parent widget then look for a macro module
|
// If the variable doesn't exist in the parent widget then look for a macro module
|
||||||
|
Loading…
Reference in New Issue
Block a user