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: {
|
|
|
|
story: {byName: "default", type: "text", optional: false},
|
|
|
|
template: {byName: true, type: "text", optional: true}
|
|
|
|
},
|
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 !== "") {
|
|
|
|
output.push("<article>");
|
2012-01-14 17:24:25 +00:00
|
|
|
if(params.template) {
|
|
|
|
output.push(store.renderTiddler(type,params.template,title));
|
|
|
|
} else {
|
|
|
|
output.push(store.renderTiddler(type,title));
|
|
|
|
}
|
2012-01-13 16:50:11 +00:00
|
|
|
output.push("</article>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return output.join("\n");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|
|
|
|
|