diff --git a/core/modules/macros/fields.js b/core/modules/macros/fields.js new file mode 100644 index 000000000..9a2514cd2 --- /dev/null +++ b/core/modules/macros/fields.js @@ -0,0 +1,67 @@ +/*\ +title: $:/core/modules/macros/fields.js +type: application/javascript +module-type: macro + +Fields macro + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "fields", + dependentOnContextTiddler: true, + params: { + } +}; + +exports.executeMacro = function() { + // Create the table + var attributes = { + "class": ["tw-fields-table"] + }; + if(this.classes) { + $tw.utils.pushTop(attributes["class"],this.classes); + } + var rows = [ + $tw.Tree.Element("tr",{},[ + $tw.Tree.Element("th",{},[$tw.Tree.Text("Field")]), + $tw.Tree.Element("th",{},[$tw.Tree.Text("Value")]) + ]) + ]; + // Get the value to display + var tiddler = this.wiki.getTiddler(this.tiddlerTitle); + if(tiddler) { + var fields = []; + for(var f in tiddler.fields) { + fields.push(f); + } + fields.sort(); + for(f=0; f - <> << <