Update the include macro to use filtering and serializing

print-window-tiddler
Jeremy Ruston 2012-05-05 13:15:59 +01:00
rodzic a753509cbf
commit e3524942cc
1 zmienionych plików z 11 dodań i 10 usunięć

Wyświetl plik

@ -13,23 +13,24 @@ module-type: macro
exports.info = {
name: "^",
params: {
target: {byPos: 0, type: "tiddler"},
filter: {byPos: 0, type: "filter"},
as: {byPos: 1, as: "text"}
}
};
exports.executeMacro = function() {
var tiddler = this.hasParameter("target") ? this.wiki.getTiddler(this.params.target) : null,
as = this.params.as,
children = [];
if(tiddler) {
as = as || tiddler.fields.as || "text/plain";
children = this.wiki.parseText(as,tiddler.fields.text).tree;
for(var t=0; t<children.length; t++) {
children[t].execute(this.parents,this.tiddlerTitle);
var as = this.params.as || "text/plain";
if(this.hasParameter("filter")) {
var titles = this.wiki.filterTiddlers(this.params.filter),
result = [];
for(var t=0; t<titles.length; t++) {
result.push(this.wiki.serializeTiddler(this.params.filter,as));
}
return [$tw.Tree.Element("pre",{},[
$tw.Tree.Text(result.join("\n"))
])];
}
return children;
return [];
};