2012-01-13 16:50:11 +00:00
|
|
|
/*\
|
|
|
|
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: {
|
2012-01-24 18:11:38 +00:00
|
|
|
story: {byName: "default", type: "tiddler", optional: false},
|
|
|
|
template: {byName: true, type: "tiddler", optional: true}
|
2012-01-13 16:50:11 +00:00
|
|
|
},
|
2012-01-15 12:16:28 +00:00
|
|
|
handler: function(type,tiddler,store,params) {
|
2012-01-14 17:24:25 +00:00
|
|
|
var tiddlers = store.getTiddlerText(params.story).split("\n"),
|
2012-01-13 16:50:11 +00:00
|
|
|
t,
|
|
|
|
output = [];
|
|
|
|
for(t=0; t<tiddlers.length; t++) {
|
|
|
|
var title = tiddlers[t].trim();
|
|
|
|
if(title !== "") {
|
2012-01-14 17:24:25 +00:00
|
|
|
if(params.template) {
|
2012-01-24 18:11:38 +00:00
|
|
|
output.push(store.renderMacro("tiddler",
|
|
|
|
type,
|
|
|
|
store.getTiddler(title),
|
|
|
|
{
|
|
|
|
target: params.template
|
|
|
|
}));
|
2012-01-14 17:24:25 +00:00
|
|
|
} else {
|
2012-01-24 18:11:38 +00:00
|
|
|
output.push(store.renderMacro("tiddler",
|
|
|
|
type,
|
|
|
|
store.getTiddler(title),
|
|
|
|
{
|
|
|
|
target: title
|
|
|
|
}));
|
2012-01-14 17:24:25 +00:00
|
|
|
}
|
2012-01-13 16:50:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return output.join("\n");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|
|
|
|
|