mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-09 13:59:41 +00:00
fc49d7dffd
Which enables us to do nice colour coded tags. Soon they'll have a drop down on them too
46 lines
949 B
JavaScript
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;
|
|
};
|
|
|
|
})();
|