1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +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.targetField = this.renderer.getAttribute("field");
this.targetIndex = this.renderer.getAttribute("index");
this.currentField = this.renderer.getAttribute("currentField");
// Get the render tree for the template
this.templateTitle = undefined;
if(this.renderer.parseTreeNode.children && this.renderer.parseTreeNode.children.length > 0) {
@ -106,6 +107,9 @@ TranscludeWidget.prototype.generate = function() {
tiddlerTitle: this.targetTitle,
templateTitle: this.templateTitle
};
if(this.currentField) {
this.renderer.context.field = this.currentField;
}
// Set the element
this.tag = this.renderer.parseTreeNode.isBlock ? "div" : "span";
this.attributes = {};