mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 23:03:50 +00:00
Rename <$value> widget to <$fill>
This commit is contained in:
parent
36cf50aa96
commit
bbd9e2f243
@ -14,7 +14,7 @@ Sub-widget used by the transclude widget for specifying values for slots within
|
|||||||
|
|
||||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||||
|
|
||||||
var ValueWidget = function(parseTreeNode,options) {
|
var FillWidget = function(parseTreeNode,options) {
|
||||||
// Initialise
|
// Initialise
|
||||||
this.initialise(parseTreeNode,options);
|
this.initialise(parseTreeNode,options);
|
||||||
};
|
};
|
||||||
@ -22,12 +22,12 @@ var ValueWidget = function(parseTreeNode,options) {
|
|||||||
/*
|
/*
|
||||||
Inherit from the base widget class
|
Inherit from the base widget class
|
||||||
*/
|
*/
|
||||||
ValueWidget.prototype = Object.create(Widget.prototype);
|
FillWidget.prototype = Object.create(Widget.prototype);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Render this widget into the DOM
|
Render this widget into the DOM
|
||||||
*/
|
*/
|
||||||
ValueWidget.prototype.render = function(parent,nextSibling) {
|
FillWidget.prototype.render = function(parent,nextSibling) {
|
||||||
// Call the constructor
|
// Call the constructor
|
||||||
Widget.call(this);
|
Widget.call(this);
|
||||||
this.parentDomNode = parent;
|
this.parentDomNode = parent;
|
||||||
@ -39,7 +39,7 @@ ValueWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
/*
|
/*
|
||||||
Compute the internal state of the widget
|
Compute the internal state of the widget
|
||||||
*/
|
*/
|
||||||
ValueWidget.prototype.execute = function() {
|
FillWidget.prototype.execute = function() {
|
||||||
// Construct the child widgets
|
// Construct the child widgets
|
||||||
this.makeChildWidgets();
|
this.makeChildWidgets();
|
||||||
};
|
};
|
||||||
@ -47,11 +47,11 @@ ValueWidget.prototype.execute = function() {
|
|||||||
/*
|
/*
|
||||||
Refresh the widget by ensuring our attributes are up to date
|
Refresh the widget by ensuring our attributes are up to date
|
||||||
*/
|
*/
|
||||||
ValueWidget.prototype.refresh = function(changedTiddlers) {
|
FillWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.value = ValueWidget;
|
exports.fill = FillWidget;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
@ -59,7 +59,7 @@ SlotWidget.prototype.execute = function() {
|
|||||||
var parseTreeNodes = [{type: "text", attributes: {text: {type: "string", value: "Missing slot reference!"}}}];
|
var parseTreeNodes = [{type: "text", attributes: {text: {type: "string", value: "Missing slot reference!"}}}];
|
||||||
if(pointer instanceof TranscludeWidget) {
|
if(pointer instanceof TranscludeWidget) {
|
||||||
// Get the parse tree nodes comprising the slot contents
|
// Get the parse tree nodes comprising the slot contents
|
||||||
parseTreeNodes = pointer.getTransclusionSlotValue(this.slotName,this.parseTreeNode.children);
|
parseTreeNodes = pointer.getTransclusionSlotFill(this.slotName,this.parseTreeNode.children);
|
||||||
}
|
}
|
||||||
// Construct the child widgets
|
// Construct the child widgets
|
||||||
this.makeChildWidgets(parseTreeNodes);
|
this.makeChildWidgets(parseTreeNodes);
|
||||||
|
@ -40,7 +40,7 @@ TranscludeWidget.prototype.execute = function() {
|
|||||||
// Get our attributes, string parameters, and slot values into properties of the widget object
|
// Get our attributes, string parameters, and slot values into properties of the widget object
|
||||||
this.collectAttributes();
|
this.collectAttributes();
|
||||||
this.collectStringParameters();
|
this.collectStringParameters();
|
||||||
this.collectSlotValueParameters();
|
this.collectSlotFillParameters();
|
||||||
// Get the parse tree nodes that we are transcluding
|
// Get the parse tree nodes that we are transcluding
|
||||||
var target = this.getTransclusionTarget(),
|
var target = this.getTransclusionTarget(),
|
||||||
parseTreeNodes = target.parseTreeNodes;
|
parseTreeNodes = target.parseTreeNodes;
|
||||||
@ -129,30 +129,30 @@ TranscludeWidget.prototype.collectStringParameters = function() {
|
|||||||
/*
|
/*
|
||||||
Collect slot value parameters
|
Collect slot value parameters
|
||||||
*/
|
*/
|
||||||
TranscludeWidget.prototype.collectSlotValueParameters = function() {
|
TranscludeWidget.prototype.collectSlotFillParameters = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.slotValueParseTrees = Object.create(null);
|
this.slotFillParseTrees = Object.create(null);
|
||||||
if(this.legacyMode) {
|
if(this.legacyMode) {
|
||||||
this.slotValueParseTrees["ts-missing"] = this.parseTreeNode.children;
|
this.slotFillParseTrees["ts-missing"] = this.parseTreeNode.children;
|
||||||
} else {
|
} else {
|
||||||
this.slotValueParseTrees["ts-raw"] = this.parseTreeNode.children;
|
this.slotFillParseTrees["ts-raw"] = this.parseTreeNode.children;
|
||||||
var noValueWidgetsFound = true,
|
var noFillWidgetsFound = true,
|
||||||
searchParseTreeNodes = function(nodes) {
|
searchParseTreeNodes = function(nodes) {
|
||||||
$tw.utils.each(nodes,function(node) {
|
$tw.utils.each(nodes,function(node) {
|
||||||
if(node.type === "value") {
|
if(node.type === "fill") {
|
||||||
if(node.attributes["$name"] && node.attributes["$name"].type === "string") {
|
if(node.attributes["$name"] && node.attributes["$name"].type === "string") {
|
||||||
var slotValueName = node.attributes["$name"].value;
|
var slotValueName = node.attributes["$name"].value;
|
||||||
self.slotValueParseTrees[slotValueName] = node.children;
|
self.slotFillParseTrees[slotValueName] = node.children;
|
||||||
}
|
}
|
||||||
noValueWidgetsFound = false;
|
noFillWidgetsFound = false;
|
||||||
} else {
|
} else {
|
||||||
searchParseTreeNodes(node.children);
|
searchParseTreeNodes(node.children);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
searchParseTreeNodes(this.parseTreeNode.children);
|
searchParseTreeNodes(this.parseTreeNode.children);
|
||||||
if(noValueWidgetsFound) {
|
if(noFillWidgetsFound) {
|
||||||
this.slotValueParseTrees["ts-missing"] = this.parseTreeNode.children;
|
this.slotFillParseTrees["ts-missing"] = this.parseTreeNode.children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -242,7 +242,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
|||||||
// If there's no parse tree then return the missing slot value
|
// If there's no parse tree then return the missing slot value
|
||||||
return {
|
return {
|
||||||
parser: null,
|
parser: null,
|
||||||
parseTreeNodes: (this.slotValueParseTrees["ts-missing"] || []),
|
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
|
||||||
parseAsInline: parseAsInline,
|
parseAsInline: parseAsInline,
|
||||||
text: null,
|
text: null,
|
||||||
type: null
|
type: null
|
||||||
@ -312,9 +312,9 @@ TranscludeWidget.prototype.getTransclusionMetaVariables = function() {
|
|||||||
/*
|
/*
|
||||||
Fetch the value of a slot
|
Fetch the value of a slot
|
||||||
*/
|
*/
|
||||||
TranscludeWidget.prototype.getTransclusionSlotValue = function(name,defaultParseTreeNodes) {
|
TranscludeWidget.prototype.getTransclusionSlotFill = function(name,defaultParseTreeNodes) {
|
||||||
if(name && this.slotValueParseTrees[name]) {
|
if(name && this.slotFillParseTrees[name]) {
|
||||||
return this.slotValueParseTrees[name];
|
return this.slotFillParseTrees[name];
|
||||||
} else {
|
} else {
|
||||||
return defaultParseTreeNodes || [];
|
return defaultParseTreeNodes || [];
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
|
|||||||
type: "transclude",
|
type: "transclude",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
type: "value",
|
type: "fill",
|
||||||
children: parseTreeNode.children
|
children: parseTreeNode.children
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -5,7 +5,7 @@ Import this component to make all the child transclusions visible.
|
|||||||
|
|
||||||
Block transclusions are shown in red, and inline transclusions are shown in green.
|
Block transclusions are shown in red, and inline transclusions are shown in green.
|
||||||
-->
|
-->
|
||||||
\procedure <$transclude>(tiddler,$tiddler,mode,$mode)
|
\widget $transclude(tiddler,$tiddler,mode,$mode)
|
||||||
<!-- Replicate the logic of the transclude widget to determine the output mode, and hence the tag and colour to use for output -->
|
<!-- Replicate the logic of the transclude widget to determine the output mode, and hence the tag and colour to use for output -->
|
||||||
<$let
|
<$let
|
||||||
mode={{{ [[$mode]is[variable]then<$mode>!is[blank]] :else[[mode]is[variable]then<mode>!is[blank]] :else[<parseAsInline>match[yes]then[inline]else[block]] }}}
|
mode={{{ [[$mode]is[variable]then<$mode>!is[blank]] :else[[mode]is[variable]then<mode>!is[blank]] :else[<parseAsInline>match[yes]then[inline]else[block]] }}}
|
||||||
@ -35,7 +35,7 @@ Block transclusions are shown in red, and inline transclusions are shown in gree
|
|||||||
""">
|
""">
|
||||||
<!-- Non-legacy mode: we use dollar signs for the recursionMarker and mode -->
|
<!-- Non-legacy mode: we use dollar signs for the recursionMarker and mode -->
|
||||||
<$genesis $type="transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>>>
|
<$genesis $type="transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>>>
|
||||||
<!-- Reach back up to the grandparent transclusion to get the correct slot value -->
|
<!-- Reach back up to the grandparent transclusion to get the correct slot fill value -->
|
||||||
<$slot $name="ts-raw" $depth="2"/>
|
<$slot $name="ts-raw" $depth="2"/>
|
||||||
</$genesis>
|
</$genesis>
|
||||||
</$list>
|
</$list>
|
||||||
|
@ -13,12 +13,12 @@ title: Output
|
|||||||
</$parameters>
|
</$parameters>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||||
<$value $name="ts-missing">
|
<$fill $name="ts-missing">
|
||||||
<$parameters one='Ferret'>
|
<$parameters one='Ferret'>
|
||||||
Badger
|
Badger
|
||||||
<$text text=<<one>>/>
|
<$text text=<<one>>/>
|
||||||
</$parameters>
|
</$parameters>
|
||||||
</$value>
|
</$fill>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||||
<$parameters one='Ferret'>
|
<$parameters one='Ferret'>
|
||||||
@ -27,12 +27,12 @@ title: Output
|
|||||||
</$parameters>
|
</$parameters>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||||
<$value $name="ts-missing">
|
<$fill $name="ts-missing">
|
||||||
<$parameters one='Ferret'>
|
<$parameters one='Ferret'>
|
||||||
Badger
|
Badger
|
||||||
<$text text=<<one>>/>
|
<$text text=<<one>>/>
|
||||||
</$parameters>
|
</$parameters>
|
||||||
</$value>
|
</$fill>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
+
|
+
|
||||||
title: TiddlerOne
|
title: TiddlerOne
|
||||||
|
@ -7,9 +7,9 @@ title: Output
|
|||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||||
<$value $name="content">
|
<$fill $name="content">
|
||||||
Hippopotamus
|
Hippopotamus
|
||||||
</$value>
|
</$fill>
|
||||||
</$transclude>
|
</$transclude>
|
||||||
+
|
+
|
||||||
title: TiddlerOne
|
title: TiddlerOne
|
||||||
|
Loading…
x
Reference in New Issue
Block a user