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

Fixed support for custom attributes, classes and tooltips on transclusions

This commit is contained in:
Jeremy Ruston 2012-12-20 17:19:28 +00:00
parent 015145952d
commit fa17eb1b96
2 changed files with 20 additions and 9 deletions

View File

@ -77,25 +77,36 @@ exports.generateChildNodes = function() {
templateParseTree = parser ? parser.tree : [];
}
}
// Create the wrapper node
var node = {
type: "element",
tag: this.renderer.parseTreeNode.isBlock ? "div" : "span",
children: templateParseTree
};
// Set up the attributes for the wrapper element
var classes = [];
if(this.renderer.hasAttribute("class")) {
$tw.utils.pushTop(classes,this.renderer.getAttribute("class").split(" "));
}
if(!this.renderer.renderTree.wiki.tiddlerExists(this.targetTitle)) {
$tw.utils.pushTop(classes,"tw-tiddler-missing");
}
if(classes.length > 0) {
$tw.utils.addClassToParseTreeNode(node,classes.join(" "));
}
if(this.renderer.hasAttribute("style")) {
$tw.utils.addAttributeToParseTreeNode(node,"style",this.renderer.getAttribute("style"));
}
if(this.renderer.hasAttribute("tooltip")) {
$tw.utils.addAttributeToParseTreeNode(node,"title",this.renderer.getAttribute("tooltip"));
}
// Create the renderers for the wrapper and the children
var newRenderContext = {
tiddlerTitle: this.targetTitle,
templateTitle: this.templateTitle,
parentContext: this.renderer.renderContext
};
this.children = this.renderer.renderTree.createRenderers(newRenderContext,[{
type: "element",
tag: this.renderer.parseTreeNode.isBlock ? "div" : "span",
attributes: {
"class": {type: "string", value: classes.join(" ")}
},
children: templateParseTree
}]);
this.children = this.renderer.renderTree.createRenderers(newRenderContext,[node]);
};
exports.refreshInDom = function(changedAttributes,changedTiddlers) {

View File

@ -22,7 +22,7 @@ Inline macro call: <<me red green>>
| this | is | a | table |
| yes | indeed |>| it is |
{{Acknowledgements}width:40;height:50;}.one
{{Acknowledgements|with a tooltip}width:40;height:50;background-color:red;}.one
And this is an inline transclusion {{Acknowledgements}width:40;height:50;}.one