1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-11 18:00:26 +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}
},
handler: function(type,tiddler,store,params) {
var v = tiddler[params.field],
encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;};
if(v) {
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;};
if(!tiddler) {
return "{{** Missing tiddler **}}";
} else {
var v = tiddler[params.field];
if(v !== undefined) {
switch(params.format) {
case "link":
return store.renderMacro("link",type,tiddler,{target: v},encoder(v));
@ -33,6 +36,7 @@ exports.macro = {
return encoder(v);
}
}
}
return "";
}
};