2012-01-07 17:33:42 +00:00
|
|
|
/*\
|
|
|
|
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: {
|
2012-01-19 11:56:06 +00:00
|
|
|
info: {byName: "default", type: "text", optional: false}
|
2012-01-07 17:33:42 +00:00
|
|
|
},
|
2012-01-15 12:16:28 +00:00
|
|
|
handler: function(type,tiddler,store,params) {
|
2012-01-07 17:33:42 +00:00
|
|
|
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;},
|
2012-01-19 11:56:06 +00:00
|
|
|
info = params.info ? params.info : "parsetree",
|
2012-01-17 13:01:55 +00:00
|
|
|
parseTree = store.parseTiddler(tiddler.title);
|
2012-01-19 11:56:06 +00:00
|
|
|
switch(info) {
|
|
|
|
case "parsetree":
|
|
|
|
return "Parse tree: " + parseTree.toString(type);
|
2012-01-21 14:03:03 +00:00
|
|
|
//break;
|
2012-01-19 11:56:06 +00:00
|
|
|
case "dependencies":
|
|
|
|
if(parseTree.dependencies === null) {
|
|
|
|
return encoder("Dependencies: *");
|
|
|
|
} else {
|
|
|
|
return encoder("Dependencies: " + parseTree.dependencies.join(", "));
|
|
|
|
}
|
|
|
|
break;
|
2012-01-07 17:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|