mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-09 19:39:57 +00:00
45 lines
1022 B
JavaScript
45 lines
1022 B
JavaScript
/*\
|
|
title: js/macros/info.js
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true */
|
|
"use strict";
|
|
|
|
var utils = require("../Utils.js");
|
|
|
|
exports.macro = {
|
|
name: "info",
|
|
types: ["text/html","text/plain"],
|
|
params: {
|
|
info: {byName: "default", type: "text", optional: false}
|
|
},
|
|
handler: function(type,tiddler,store,params) {
|
|
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;},
|
|
info = params.info ? params.info : "parsetree";
|
|
if(tiddler) {
|
|
var parseTree = store.parseTiddler(tiddler.title);
|
|
switch(info) {
|
|
case "parsetree":
|
|
return "Parse tree: " + parseTree.toString(type);
|
|
//break;
|
|
case "compiled":
|
|
return "Compiled as: " + utils.stitchElement("pre",null,{
|
|
content: encoder(parseTree.compile(type))
|
|
});
|
|
//break;
|
|
case "dependencies":
|
|
if(parseTree.dependencies === null) {
|
|
return encoder("Dependencies: *");
|
|
} else {
|
|
return encoder("Dependencies: " + parseTree.dependencies.join(", "));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
})();
|