mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 09:50:27 +00:00
Refactored macros to use new Dependencies() constructor
This commit is contained in:
parent
b1a96d8bf5
commit
b37d3b6670
@ -38,15 +38,18 @@ exports.macro = {
|
||||
},
|
||||
execute: function(macroNode,tiddler,store) {
|
||||
var isOpen = macroNode.params.state ? store.getTiddlerText(macroNode.params.state,"").trim() === "open" : true,
|
||||
target = macroNode.params.targetTiddler,
|
||||
dependencies = new Dependencies();
|
||||
dependencies.addDependency(target,true);
|
||||
target = macroNode.params.targetTiddler;
|
||||
var content = Renderer.SliderNode(macroNode.params.state,
|
||||
macroNode.params.label ? macroNode.params.label : target,
|
||||
macroNode.params.tooltip,
|
||||
isOpen,
|
||||
[
|
||||
Renderer.MacroNode("tiddler",{target: target},null,dependencies,store)
|
||||
Renderer.MacroNode(
|
||||
"tiddler",
|
||||
{target: target},
|
||||
null,
|
||||
new Dependencies([],[target]),
|
||||
store)
|
||||
]);
|
||||
content.execute(macroNode.parents,tiddler);
|
||||
return [content];
|
||||
|
@ -47,13 +47,11 @@ exports.macro = {
|
||||
var tiddlers = parseStory(store.getTiddlerText(macroNode.params.story)),
|
||||
content = [];
|
||||
for(var t=0; t<tiddlers.length; t++) {
|
||||
var paramFn = {target: tiddlers[t],template: macroNode.params.template},
|
||||
dependencies = new Dependencies();
|
||||
dependencies.addDependency(tiddlers[t],true);
|
||||
if(macroNode.params.template) {
|
||||
dependencies.addDependency(macroNode.params.template,true);
|
||||
}
|
||||
var m = Renderer.MacroNode("tiddler",paramFn,null,dependencies,store);
|
||||
var m = Renderer.MacroNode("tiddler",
|
||||
{target: tiddlers[t],template: macroNode.params.template},
|
||||
null,
|
||||
new Dependencies([],[tiddlers[t],macroNode.params.template]),
|
||||
store);
|
||||
m.execute(macroNode.parents,tiddler);
|
||||
content.push(m);
|
||||
}
|
||||
@ -82,13 +80,11 @@ exports.macro = {
|
||||
var tiddlerNode = findTiddler(t,targetTiddlers[t],template);
|
||||
if(tiddlerNode === null) {
|
||||
// If not, render the tiddler
|
||||
var paramFn = {target: targetTiddlers[t],template: template},
|
||||
dependencies = new Dependencies();
|
||||
dependencies.addDependency(targetTiddlers[t],true);
|
||||
if(template) {
|
||||
dependencies.addDependency(template,true);
|
||||
}
|
||||
var m = Renderer.MacroNode("tiddler",paramFn,null,dependencies,store);
|
||||
var m = Renderer.MacroNode("tiddler",
|
||||
{target: targetTiddlers[t],template: template},
|
||||
null,
|
||||
new Dependencies([],[targetTiddlers[t],template]),
|
||||
store);
|
||||
m.execute(macroNode.parents,store.getTiddler(targetTiddlers[t]));
|
||||
m.renderInDom(macroNode.domNode,macroNode.domNode.childNodes[t]);
|
||||
macroNode.content.splice(t,0,m);
|
||||
|
@ -31,12 +31,10 @@ exports.macro = {
|
||||
if(v !== undefined) {
|
||||
switch(macroNode.params.format) {
|
||||
case "link":
|
||||
var dependencies = new Dependencies();
|
||||
dependencies.addDependency(v,false);
|
||||
var link = Renderer.MacroNode("link",
|
||||
{target: v},
|
||||
[Renderer.TextNode(v)],
|
||||
dependencies,
|
||||
new Dependencies([v]),
|
||||
store);
|
||||
link.execute(parents,tiddler);
|
||||
return [link];
|
||||
|
Loading…
Reference in New Issue
Block a user