mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-29 15:30:47 +00:00
Added verification of macro type compatibility
This commit is contained in:
parent
7a0f94343a
commit
3a98cc5389
@ -80,7 +80,14 @@ WikiTextParseTree.prototype.compileMacroCall = function(type,name,params) {
|
||||
var macro = this.store.macros[name],
|
||||
p,
|
||||
n;
|
||||
if(macro) {
|
||||
if(!macro) {
|
||||
this.pushString("{{** Unknown macro '" + name + "' **}}");
|
||||
return;
|
||||
}
|
||||
if(macro.types.indexOf(type) === -1) {
|
||||
this.pushString("{{** Macro '" + name + "' cannot render to MIME type '" + type + "'**}}");
|
||||
return;
|
||||
}
|
||||
var macroCall = {
|
||||
type: "FunctionCall",
|
||||
name: {
|
||||
@ -88,33 +95,25 @@ WikiTextParseTree.prototype.compileMacroCall = function(type,name,params) {
|
||||
"base": {
|
||||
"base": {
|
||||
"name": "store",
|
||||
"type": "Variable"
|
||||
},
|
||||
"type": "Variable"},
|
||||
"name": "macros",
|
||||
"type": "PropertyAccess"
|
||||
},
|
||||
"type": "PropertyAccess"},
|
||||
"name": {
|
||||
"type": "StringLiteral",
|
||||
"value": name
|
||||
},
|
||||
"type": "PropertyAccess"
|
||||
},
|
||||
"value": name},
|
||||
"type": "PropertyAccess"},
|
||||
"name": "code",
|
||||
"type": "PropertyAccess"
|
||||
},
|
||||
"type": "PropertyAccess"},
|
||||
"arguments": [ {
|
||||
"type": "StringLiteral",
|
||||
"value": type
|
||||
},
|
||||
{
|
||||
},{
|
||||
"type": "Variable",
|
||||
"name": "tiddler"
|
||||
},
|
||||
{
|
||||
},{
|
||||
"type": "Variable",
|
||||
"name": "store"
|
||||
},
|
||||
{
|
||||
},{
|
||||
type: "ObjectLiteral",
|
||||
properties: []
|
||||
}]
|
||||
@ -132,9 +131,6 @@ WikiTextParseTree.prototype.compileMacroCall = function(type,name,params) {
|
||||
});
|
||||
}
|
||||
this.output.push(macroCall);
|
||||
} else {
|
||||
this.pushString("{{** Unknown macro '" + name + "' **}}");
|
||||
}
|
||||
};
|
||||
|
||||
WikiTextParseTree.prototype.compileElementHtml = function(element, options) {
|
||||
|
Loading…
Reference in New Issue
Block a user