1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-23 07:26:54 +00:00

Rename render function of macros

This commit is contained in:
Jeremy Ruston 2012-01-30 20:04:47 +00:00
parent 350ad5bf3b
commit ddfa6732a6
12 changed files with 16 additions and 16 deletions

View File

@ -373,13 +373,17 @@ WikiStore.prototype.renderTiddler = function(targetType,title,asTitle,options) {
return null; return null;
}; };
WikiStore.prototype.installMacro = function(macro) {
this.macros[macro.name] = macro;
};
/* /*
Executes a macro and returns the result Executes a macro and returns the result
*/ */
WikiStore.prototype.renderMacro = function(macroName,targetType,tiddler,params,content) { WikiStore.prototype.renderMacro = function(macroName,targetType,tiddler,params,content) {
var macro = this.macros[macroName]; var macro = this.macros[macroName];
if(macro) { if(macro) {
return macro.handler(targetType,tiddler,this,params,content); return macro.render(targetType,tiddler,this,params,content);
} else { } else {
return null; return null;
} }
@ -443,10 +447,6 @@ WikiStore.prototype.refreshDomNode = function(node,changes,renderer,tiddler) {
} }
}; };
WikiStore.prototype.installMacro = function(macro) {
this.macros[macro.name] = macro;
};
exports.WikiStore = WikiStore; exports.WikiStore = WikiStore;
})(); })();

View File

@ -123,7 +123,7 @@ WikiTextParseTree.prototype.compileMacroCall = function(output,renderer,type,nod
type: "StringLiteral", type: "StringLiteral",
value: name}, value: name},
type: "PropertyAccess"}, type: "PropertyAccess"},
name: "handler", name: "render",
type: "PropertyAccess"}, type: "PropertyAccess"},
"arguments": [ { "arguments": [ {
type: "StringLiteral", type: "StringLiteral",

View File

@ -15,7 +15,7 @@ exports.macro = {
params: { params: {
text: {byPos: 0, type: "text", optional: false} text: {byPos: 0, type: "text", optional: false}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
if(type === "text/html") { if(type === "text/html") {
return utils.htmlEncode(params.text); return utils.htmlEncode(params.text);
} else { } else {

View File

@ -17,7 +17,7 @@ exports.macro = {
text: {byName: true, type: "text", optional: true}, text: {byName: true, type: "text", optional: true},
alignment: {byName: true, type: "text", optional: true} alignment: {byName: true, type: "text", optional: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
if(type === "text/html") { if(type === "text/html") {
if(store.tiddlerExists(params.src)) { if(store.tiddlerExists(params.src)) {
if(params.text) { if(params.text) {

View File

@ -15,7 +15,7 @@ exports.macro = {
params: { params: {
info: {byName: "default", type: "text", optional: false} info: {byName: "default", type: "text", optional: false}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;}, var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;},
info = params.info || "parsetree"; info = params.info || "parsetree";
if(tiddler) { if(tiddler) {

View File

@ -16,7 +16,7 @@ exports.macro = {
params: { params: {
target: {byName: "default", type: "tiddler", optional: false} target: {byName: "default", type: "tiddler", optional: false}
}, },
handler: function(type,tiddler,store,params,content) { render: function(type,tiddler,store,params,content) {
if(type === "text/html") { if(type === "text/html") {
return utils.stitchElement("a",{ return utils.stitchElement("a",{
href: params.target href: params.target

View File

@ -41,7 +41,7 @@ exports.macro = {
template: {byName: true, type: "tiddler", optional: true}, template: {byName: true, type: "tiddler", optional: true},
emptyMessage: {byName: true, type: "text", optional: true} emptyMessage: {byName: true, type: "text", optional: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
var templateType = "text/x-tiddlywiki", var templateType = "text/x-tiddlywiki",
templateText = "<<view title link>>", templateText = "<<view title link>>",
template = params.template ? store.getTiddler(params.template) : null, template = params.template ? store.getTiddler(params.template) : null,

View File

@ -18,7 +18,7 @@ exports.macro = {
label: {byPos: 2, type: "text", optional: false}, label: {byPos: 2, type: "text", optional: false},
tooltip: {byPos: 3, type: "text", optional: true} tooltip: {byPos: 3, type: "text", optional: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
if(type === "text/html") { if(type === "text/html") {
return utils.stitchSlider(type, return utils.stitchSlider(type,
params.label, params.label,

View File

@ -16,7 +16,7 @@ exports.macro = {
story: {byName: "default", type: "tiddler", optional: false}, story: {byName: "default", type: "tiddler", optional: false},
template: {byName: true, type: "tiddler", optional: true} template: {byName: true, type: "tiddler", optional: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
var tiddlers = store.getTiddlerText(params.story).split("\n"), var tiddlers = store.getTiddlerText(params.story).split("\n"),
t, t,
output = []; output = [];

View File

@ -53,7 +53,7 @@ exports.macro = {
template: {byName: true, type: "tiddler", optional: true}, template: {byName: true, type: "tiddler", optional: true},
"with": {byName: true, type: "text", optional: true, dependentAll: true} "with": {byName: true, type: "text", optional: true, dependentAll: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
var renderTitle = params.template, var renderTitle = params.template,
renderAs = params.target; renderAs = params.target;
// Slightly bewildering logic to sort out the optional parameters // Slightly bewildering logic to sort out the optional parameters

View File

@ -14,7 +14,7 @@ exports.macro = {
types: ["text/html","text/plain"], types: ["text/html","text/plain"],
params: { params: {
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
return "5.0.0"; return "5.0.0";
} }
}; };

View File

@ -17,7 +17,7 @@ exports.macro = {
format: {byPos: 1, type: "text", optional: true}, format: {byPos: 1, type: "text", optional: true},
template: {byPos: 2, type: "text", optional: true} template: {byPos: 2, type: "text", optional: true}
}, },
handler: function(type,tiddler,store,params) { render: function(type,tiddler,store,params) {
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;}; var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;};
if(!tiddler) { if(!tiddler) {
return "{{** Missing tiddler **}}"; return "{{** Missing tiddler **}}";