mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-04 15:29:56 +00:00
Fix up handling of slot/fill for custom widgets
Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget
This commit is contained in:
parent
defe3e42e6
commit
79b20bdaa8
@ -509,16 +509,10 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
|
|||||||
if(!parseTreeNode.isNotRemappable && isOverrideable() && variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.value && variableInfo.srcVariable.isWidgetDefinition) {
|
if(!parseTreeNode.isNotRemappable && isOverrideable() && variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.value && variableInfo.srcVariable.isWidgetDefinition) {
|
||||||
var newParseTreeNode = {
|
var newParseTreeNode = {
|
||||||
type: "transclude",
|
type: "transclude",
|
||||||
children: [
|
children: parseTreeNode.children,
|
||||||
{
|
|
||||||
type: "fill",
|
|
||||||
children: parseTreeNode.children
|
|
||||||
}
|
|
||||||
],
|
|
||||||
isBlock: parseTreeNode.isBlock
|
isBlock: parseTreeNode.isBlock
|
||||||
};
|
};
|
||||||
$tw.utils.addAttributeToParseTreeNode(newParseTreeNode,"$variable",variableDefinitionName);
|
$tw.utils.addAttributeToParseTreeNode(newParseTreeNode,"$variable",variableDefinitionName);
|
||||||
$tw.utils.addAttributeToParseTreeNode(newParseTreeNode.children[0],"$name","ts-body");
|
|
||||||
$tw.utils.each(parseTreeNode.attributes,function(attr,name) {
|
$tw.utils.each(parseTreeNode.attributes,function(attr,name) {
|
||||||
// If the attribute starts with a dollar then add an extra dollar so that it doesn't clash with the $xxx attributes of transclude
|
// If the attribute starts with a dollar then add an extra dollar so that it doesn't clash with the $xxx attributes of transclude
|
||||||
name = name.charAt(0) === "$" ? "$" + name : name;
|
name = name.charAt(0) === "$" ? "$" + name : name;
|
||||||
|
@ -10,7 +10,7 @@ title: Output
|
|||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$parameters $params="@params">
|
<$parameters $params="@params">
|
||||||
<$setmultiplevariables $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>addprefix[--]addsuffix[--]]">
|
<$setmultiplevariables $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>addprefix[--]addsuffix[--]]">
|
||||||
<$slot $name="ts-body"/>
|
<$slot $name="ts-raw"/>
|
||||||
</$setmultiplevariables>
|
</$setmultiplevariables>
|
||||||
</$parameters>
|
</$parameters>
|
||||||
\end
|
\end
|
||||||
|
@ -15,7 +15,7 @@ title: $:/global/$$mywidget
|
|||||||
_is_widget: yes
|
_is_widget: yes
|
||||||
_parameters: (foo:"bar")
|
_parameters: (foo:"bar")
|
||||||
|
|
||||||
Koala! <$text text=<<foo>>/>, <$slot $name="ts-body"/>
|
Koala! <$text text=<<foo>>/>, <$slot $name="ts-raw"/>
|
||||||
+
|
+
|
||||||
title: ExpectedResult
|
title: ExpectedResult
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ title: Output
|
|||||||
\widget $non-existent-widget(one:'Jaguar')
|
\widget $non-existent-widget(one:'Jaguar')
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$text text=<<one>>/>
|
<$text text=<<one>>/>
|
||||||
<$slot $name="ts-body">
|
<$slot $name="ts-raw">
|
||||||
Whale
|
Whale
|
||||||
</$slot>
|
</$slot>
|
||||||
\end
|
\end
|
||||||
|
@ -16,7 +16,7 @@ title: TiddlerOne
|
|||||||
\widget $$mywidget(one:'Jaguar')
|
\widget $$mywidget(one:'Jaguar')
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$text text=<<one>>/>
|
<$text text=<<one>>/>
|
||||||
<$slot $name="ts-body">
|
<$slot $name="ts-raw">
|
||||||
Whale
|
Whale
|
||||||
</$slot>
|
</$slot>
|
||||||
\end
|
\end
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
title: Transclude/CustomWidget/Slotted
|
||||||
|
description: Custom widget definition
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\widget $$mywidget(one:'Jaguar')
|
||||||
|
\whitespace trim
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
<$slot $name="ts-stuff">
|
||||||
|
Whale
|
||||||
|
</$slot>
|
||||||
|
\end
|
||||||
|
<$$mywidget one="Dingo">
|
||||||
|
<$fill $name="ts-stuff">
|
||||||
|
Crocodile
|
||||||
|
</$fill>
|
||||||
|
</$$mywidget>
|
||||||
|
<$$mywidget one="BumbleBee">
|
||||||
|
Squirrel
|
||||||
|
</$$mywidget>
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>DingoCrocodileBumbleBeeWhale</p>
|
@ -17,7 +17,7 @@ title: TiddlerOne
|
|||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$genesis $type="text" $remappable="no" text=<<text>>/>
|
<$genesis $type="text" $remappable="no" text=<<text>>/>
|
||||||
<$set name="$text" value="">
|
<$set name="$text" value="">
|
||||||
<$slot $name="ts-body">
|
<$slot $name="ts-raw">
|
||||||
Whale
|
Whale
|
||||||
</$slot>
|
</$slot>
|
||||||
</$set>
|
</$set>
|
||||||
|
@ -16,7 +16,7 @@ title: TiddlerOne
|
|||||||
\widget $$mywidget($variable:'Jaguar')
|
\widget $$mywidget($variable:'Jaguar')
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$text text=<<$variable>>/>
|
<$text text=<<$variable>>/>
|
||||||
<$slot $name="ts-body">
|
<$slot $name="ts-raw">
|
||||||
Whale
|
Whale
|
||||||
</$slot>
|
</$slot>
|
||||||
\end
|
\end
|
||||||
|
Loading…
Reference in New Issue
Block a user