Refactored story macro to use renderTiddler instead of renderText

print-window-tiddler
Jeremy Ruston 2012-01-14 17:24:25 +00:00
rodzic 7c4d5b76ef
commit b671ecdedd
1 zmienionych plików z 6 dodań i 9 usunięć

Wyświetl plik

@ -17,21 +17,18 @@ exports.macro = {
template: {byName: true, type: "text", optional: true} template: {byName: true, type: "text", optional: true}
}, },
code: function(type,tiddler,store,params) { code: function(type,tiddler,store,params) {
var templateType = "text/x-tiddlywiki", var tiddlers = store.getTiddlerText(params.story).split("\n"),
templateText = "<<view text wikified>>",
template = params.template ? store.getTiddler(params.template) : null,
tiddlers = store.getTiddlerText(params.story).split("\n"),
t, t,
output = []; output = [];
if(template) {
templateType = template.fields.type;
templateText = template.fields.text;
}
for(t=0; t<tiddlers.length; t++) { for(t=0; t<tiddlers.length; t++) {
var title = tiddlers[t].trim(); var title = tiddlers[t].trim();
if(title !== "") { if(title !== "") {
output.push("<article>"); output.push("<article>");
output.push(store.renderText(templateType,templateText,"text/html",title)); if(params.template) {
output.push(store.renderTiddler(type,params.template,title));
} else {
output.push(store.renderTiddler(type,title));
}
output.push("</article>"); output.push("</article>");
} }
} }