mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-03 14:59:57 +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) {
|
||||
var newParseTreeNode = {
|
||||
type: "transclude",
|
||||
children: [
|
||||
{
|
||||
type: "fill",
|
||||
children: parseTreeNode.children
|
||||
}
|
||||
],
|
||||
children: parseTreeNode.children,
|
||||
isBlock: parseTreeNode.isBlock
|
||||
};
|
||||
$tw.utils.addAttributeToParseTreeNode(newParseTreeNode,"$variable",variableDefinitionName);
|
||||
$tw.utils.addAttributeToParseTreeNode(newParseTreeNode.children[0],"$name","ts-body");
|
||||
$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
|
||||
name = name.charAt(0) === "$" ? "$" + name : name;
|
||||
|
@ -10,7 +10,7 @@ title: Output
|
||||
\whitespace trim
|
||||
<$parameters $params="@params">
|
||||
<$setmultiplevariables $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>addprefix[--]addsuffix[--]]">
|
||||
<$slot $name="ts-body"/>
|
||||
<$slot $name="ts-raw"/>
|
||||
</$setmultiplevariables>
|
||||
</$parameters>
|
||||
\end
|
||||
|
@ -15,7 +15,7 @@ title: $:/global/$$mywidget
|
||||
_is_widget: yes
|
||||
_parameters: (foo:"bar")
|
||||
|
||||
Koala! <$text text=<<foo>>/>, <$slot $name="ts-body"/>
|
||||
Koala! <$text text=<<foo>>/>, <$slot $name="ts-raw"/>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
|
@ -10,7 +10,7 @@ title: Output
|
||||
\widget $non-existent-widget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="ts-body">
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
|
@ -16,7 +16,7 @@ title: TiddlerOne
|
||||
\widget $$mywidget(one:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<one>>/>
|
||||
<$slot $name="ts-body">
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\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
|
||||
<$genesis $type="text" $remappable="no" text=<<text>>/>
|
||||
<$set name="$text" value="">
|
||||
<$slot $name="ts-body">
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
</$set>
|
||||
|
@ -16,7 +16,7 @@ title: TiddlerOne
|
||||
\widget $$mywidget($variable:'Jaguar')
|
||||
\whitespace trim
|
||||
<$text text=<<$variable>>/>
|
||||
<$slot $name="ts-body">
|
||||
<$slot $name="ts-raw">
|
||||
Whale
|
||||
</$slot>
|
||||
\end
|
||||
|
Loading…
Reference in New Issue
Block a user