Split "transclude" widget into a separate "tiddler" and "transclude" widget

Belatedly realised that the design would be clearer without these two
separate concepts being conflated into a single widget.

As a result of this change, any other widget or template that generates
transclude widgets has needed adjustment.
This commit is contained in:
Jeremy Ruston
2013-08-24 16:45:45 +01:00
parent 6c5239603c
commit be06257430
19 changed files with 259 additions and 151 deletions

View File

@@ -42,33 +42,38 @@ exports.parse = function() {
template = $tw.utils.trim(this.match[3]),
style = this.match[4],
classes = this.match[5];
// Return the transclude widget
var node = {
// Prepare the transclude widget
var transcludeNode = {
type: "element",
tag: "$transclude",
attributes: {
title: {type: "string", value: template || targetTitle}
}
};
var tiddlerNode = {
type: "element",
tag: "$transclude",
tag: "$tiddler",
attributes: {
target: {type: "string", value: targetTitle}
}
title: {type: "string", value: targetTitle}
},
children: [transcludeNode]
};
if(targetField) {
node.attributes.field = {type: "string", value: targetField};
transcludeNode.attributes.field = {type: "string", value: targetField};
}
if(targetIndex) {
node.attributes.index = {type: "string", value: targetIndex};
transcludeNode.attributes.index = {type: "string", value: targetIndex};
}
if(tooltip) {
node.attributes.tooltip = {type: "string", value: tooltip};
}
if(template) {
node.attributes.template = {type: "string", value: template};
transcludeNode.attributes.tooltip = {type: "string", value: tooltip};
}
if(style) {
node.attributes.style = {type: "string", value: style};
transcludeNode.attributes.style = {type: "string", value: style};
}
if(classes) {
node.attributes["class"] = {type: "string", value: classes.split(".").join(" ")};
transcludeNode.attributes["class"] = {type: "string", value: classes.split(".").join(" ")};
}
return [node];
return [tiddlerNode];
};
})();