1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-29 07:10:37 +00:00
TiddlyWiki5/core/modules/macros/tags.js
Jeremy Ruston fc49d7dffd Added tags and color macros
Which enables us to do nice colour coded tags. Soon they'll have a drop
down on them too
2012-06-10 19:47:24 +01:00

46 lines
949 B
JavaScript

/*\
title: $:/core/modules/macros/tags.js
type: application/javascript
module-type: macro
Implements the tags macro.
{{{
<<tags template:MyTagTemplate>>
}}}
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "tags",
dependentOnContextTiddler: true,
params: {
template: {byName: true, type: "tiddler"},
filter: {byName: true, type: "filter"}
}
};
exports.executeMacro = function() {
var tiddler = this.wiki.getTiddler(this.tiddlerTitle),
child = $tw.Tree.Element("div",{"class":"tw-tags-wrapper"},[]);
if(tiddler && tiddler.fields.tags) {
for(var t=0; t<tiddler.fields.tags.length; t++) {
var tag = tiddler.fields.tags[t];
child.children.push($tw.Tree.Macro("tiddler",{
srcParams: {target: tag,template: this.params.template},
wiki: this.wiki,
isBlock: false
}));
}
}
child.execute(this.parents,this.tiddlerTitle);
return child;
};
})();