1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-04 21:03:55 +00:00

Refactored the story macro to invoke the tiddler macro to display tiddlers

This commit is contained in:
Jeremy Ruston 2012-01-24 18:11:38 +00:00
parent 3268c46458
commit 04e9376eca

View File

@ -13,8 +13,8 @@ exports.macro = {
name: "story", name: "story",
types: ["text/html","text/plain"], types: ["text/html","text/plain"],
params: { params: {
story: {byName: "default", type: "text", optional: false}, story: {byName: "default", type: "tiddler", optional: false},
template: {byName: true, type: "text", optional: true} template: {byName: true, type: "tiddler", optional: true}
}, },
handler: function(type,tiddler,store,params) { handler: function(type,tiddler,store,params) {
var tiddlers = store.getTiddlerText(params.story).split("\n"), var tiddlers = store.getTiddlerText(params.story).split("\n"),
@ -23,13 +23,21 @@ exports.macro = {
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>");
if(params.template) { if(params.template) {
output.push(store.renderTiddler(type,params.template,title)); output.push(store.renderMacro("tiddler",
type,
store.getTiddler(title),
{
target: params.template
}));
} else { } else {
output.push(store.renderTiddler(type,title)); output.push(store.renderMacro("tiddler",
type,
store.getTiddler(title),
{
target: title
}));
} }
output.push("</article>");
} }
} }
return output.join("\n"); return output.join("\n");