1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-04 17:16:18 +00:00

Extend the transclude widget to allow a currentField to be set

We set the current field as a context variable for the transcluded
content
This commit is contained in:
Jeremy Ruston 2013-06-02 23:19:50 +01:00
parent 456d50b6ef
commit d5b0a0fb68

View File

@ -59,6 +59,7 @@ TranscludeWidget.prototype.generate = function() {
this.targetTitle = this.renderer.getAttribute("target",this.renderer.tiddlerTitle); this.targetTitle = this.renderer.getAttribute("target",this.renderer.tiddlerTitle);
this.targetField = this.renderer.getAttribute("field"); this.targetField = this.renderer.getAttribute("field");
this.targetIndex = this.renderer.getAttribute("index"); this.targetIndex = this.renderer.getAttribute("index");
this.currentField = this.renderer.getAttribute("currentField");
// Get the render tree for the template // Get the render tree for the template
this.templateTitle = undefined; this.templateTitle = undefined;
if(this.renderer.parseTreeNode.children && this.renderer.parseTreeNode.children.length > 0) { if(this.renderer.parseTreeNode.children && this.renderer.parseTreeNode.children.length > 0) {
@ -106,6 +107,9 @@ TranscludeWidget.prototype.generate = function() {
tiddlerTitle: this.targetTitle, tiddlerTitle: this.targetTitle,
templateTitle: this.templateTitle templateTitle: this.templateTitle
}; };
if(this.currentField) {
this.renderer.context.field = this.currentField;
}
// Set the element // Set the element
this.tag = this.renderer.parseTreeNode.isBlock ? "div" : "span"; this.tag = this.renderer.parseTreeNode.isBlock ? "div" : "span";
this.attributes = {}; this.attributes = {};