Added verification of macro type compatibility

print-window-tiddler
Jeremy Ruston 2012-01-07 18:33:57 +00:00
rodzic 7a0f94343a
commit 3a98cc5389
1 zmienionych plików z 47 dodań i 51 usunięć

Wyświetl plik

@ -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) {