1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-26 00:46:52 +00:00

Fixed view macro to check whether the tiddler exists

This commit is contained in:
Jeremy Ruston 2012-01-23 16:42:12 +00:00
parent 82a37d3ab4
commit c185989ca5

View File

@ -18,9 +18,12 @@ exports.macro = {
template: {byPos: 2, type: "text", optional: true} template: {byPos: 2, type: "text", optional: true}
}, },
handler: function(type,tiddler,store,params) { handler: function(type,tiddler,store,params) {
var v = tiddler[params.field], var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;};
encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;}; if(!tiddler) {
if(v) { return "{{** Missing tiddler **}}";
} else {
var v = tiddler[params.field];
if(v !== undefined) {
switch(params.format) { switch(params.format) {
case "link": case "link":
return store.renderMacro("link",type,tiddler,{target: v},encoder(v)); return store.renderMacro("link",type,tiddler,{target: v},encoder(v));
@ -33,6 +36,7 @@ exports.macro = {
return encoder(v); return encoder(v);
} }
} }
}
return ""; return "";
} }
}; };