1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-27 05:06:17 +00:00
TiddlyWiki5/js/macros/story.js

49 lines
976 B
JavaScript
Raw Normal View History

/*\
title: js/macros/story.js
\*/
(function(){
/*jslint node: true */
"use strict";
var utils = require("../Utils.js");
exports.macro = {
name: "story",
types: ["text/html","text/plain"],
params: {
story: {byName: "default", type: "tiddler", optional: false},
template: {byName: true, type: "tiddler", optional: true}
},
handler: function(type,tiddler,store,params) {
var tiddlers = store.getTiddlerText(params.story).split("\n"),
t,
output = [];
for(t=0; t<tiddlers.length; t++) {
var title = tiddlers[t].trim();
if(title !== "") {
if(params.template) {
output.push(store.renderMacro("tiddler",
type,
store.getTiddler(title),
{
target: params.template
}));
} else {
output.push(store.renderMacro("tiddler",
type,
store.getTiddler(title),
{
target: title
}));
}
}
}
return output.join("\n");
}
};
})();