mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +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 ValueWidget = function(parseTreeNode,options) {
|
||||
var FillWidget = function(parseTreeNode,options) {
|
||||
// Initialise
|
||||
this.initialise(parseTreeNode,options);
|
||||
};
|
||||
@ -22,12 +22,12 @@ var ValueWidget = function(parseTreeNode,options) {
|
||||
/*
|
||||
Inherit from the base widget class
|
||||
*/
|
||||
ValueWidget.prototype = Object.create(Widget.prototype);
|
||||
FillWidget.prototype = Object.create(Widget.prototype);
|
||||
|
||||
/*
|
||||
Render this widget into the DOM
|
||||
*/
|
||||
ValueWidget.prototype.render = function(parent,nextSibling) {
|
||||
FillWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Call the constructor
|
||||
Widget.call(this);
|
||||
this.parentDomNode = parent;
|
||||
@ -39,7 +39,7 @@ ValueWidget.prototype.render = function(parent,nextSibling) {
|
||||
/*
|
||||
Compute the internal state of the widget
|
||||
*/
|
||||
ValueWidget.prototype.execute = function() {
|
||||
FillWidget.prototype.execute = function() {
|
||||
// Construct the child widgets
|
||||
this.makeChildWidgets();
|
||||
};
|
||||
@ -47,11 +47,11 @@ ValueWidget.prototype.execute = function() {
|
||||
/*
|
||||
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);
|
||||
};
|
||||
|
||||
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!"}}}];
|
||||
if(pointer instanceof TranscludeWidget) {
|
||||
// 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
|
||||
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
|
||||
this.collectAttributes();
|
||||
this.collectStringParameters();
|
||||
this.collectSlotValueParameters();
|
||||
this.collectSlotFillParameters();
|
||||
// Get the parse tree nodes that we are transcluding
|
||||
var target = this.getTransclusionTarget(),
|
||||
parseTreeNodes = target.parseTreeNodes;
|
||||
@ -129,30 +129,30 @@ TranscludeWidget.prototype.collectStringParameters = function() {
|
||||
/*
|
||||
Collect slot value parameters
|
||||
*/
|
||||
TranscludeWidget.prototype.collectSlotValueParameters = function() {
|
||||
TranscludeWidget.prototype.collectSlotFillParameters = function() {
|
||||
var self = this;
|
||||
this.slotValueParseTrees = Object.create(null);
|
||||
this.slotFillParseTrees = Object.create(null);
|
||||
if(this.legacyMode) {
|
||||
this.slotValueParseTrees["ts-missing"] = this.parseTreeNode.children;
|
||||
this.slotFillParseTrees["ts-missing"] = this.parseTreeNode.children;
|
||||
} else {
|
||||
this.slotValueParseTrees["ts-raw"] = this.parseTreeNode.children;
|
||||
var noValueWidgetsFound = true,
|
||||
this.slotFillParseTrees["ts-raw"] = this.parseTreeNode.children;
|
||||
var noFillWidgetsFound = true,
|
||||
searchParseTreeNodes = function(nodes) {
|
||||
$tw.utils.each(nodes,function(node) {
|
||||
if(node.type === "value") {
|
||||
if(node.type === "fill") {
|
||||
if(node.attributes["$name"] && node.attributes["$name"].type === "string") {
|
||||
var slotValueName = node.attributes["$name"].value;
|
||||
self.slotValueParseTrees[slotValueName] = node.children;
|
||||
self.slotFillParseTrees[slotValueName] = node.children;
|
||||
}
|
||||
noValueWidgetsFound = false;
|
||||
noFillWidgetsFound = false;
|
||||
} else {
|
||||
searchParseTreeNodes(node.children);
|
||||
}
|
||||
});
|
||||
};
|
||||
searchParseTreeNodes(this.parseTreeNode.children);
|
||||
if(noValueWidgetsFound) {
|
||||
this.slotValueParseTrees["ts-missing"] = this.parseTreeNode.children;
|
||||
if(noFillWidgetsFound) {
|
||||
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
|
||||
return {
|
||||
parser: null,
|
||||
parseTreeNodes: (this.slotValueParseTrees["ts-missing"] || []),
|
||||
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
|
||||
parseAsInline: parseAsInline,
|
||||
text: null,
|
||||
type: null
|
||||
@ -312,9 +312,9 @@ TranscludeWidget.prototype.getTransclusionMetaVariables = function() {
|
||||
/*
|
||||
Fetch the value of a slot
|
||||
*/
|
||||
TranscludeWidget.prototype.getTransclusionSlotValue = function(name,defaultParseTreeNodes) {
|
||||
if(name && this.slotValueParseTrees[name]) {
|
||||
return this.slotValueParseTrees[name];
|
||||
TranscludeWidget.prototype.getTransclusionSlotFill = function(name,defaultParseTreeNodes) {
|
||||
if(name && this.slotFillParseTrees[name]) {
|
||||
return this.slotFillParseTrees[name];
|
||||
} else {
|
||||
return defaultParseTreeNodes || [];
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
|
||||
type: "transclude",
|
||||
children: [
|
||||
{
|
||||
type: "value",
|
||||
type: "fill",
|
||||
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.
|
||||
-->
|
||||
\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 -->
|
||||
<$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]] }}}
|
||||
@ -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 -->
|
||||
<$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"/>
|
||||
</$genesis>
|
||||
</$list>
|
||||
|
@ -13,12 +13,12 @@ title: Output
|
||||
</$parameters>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$value $name="ts-missing">
|
||||
<$fill $name="ts-missing">
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$value>
|
||||
</$fill>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||
<$parameters one='Ferret'>
|
||||
@ -27,12 +27,12 @@ title: Output
|
||||
</$parameters>
|
||||
</$transclude>
|
||||
<$transclude $tiddler='MissingTiddler' one='Ferret'>
|
||||
<$value $name="ts-missing">
|
||||
<$fill $name="ts-missing">
|
||||
<$parameters one='Ferret'>
|
||||
Badger
|
||||
<$text text=<<one>>/>
|
||||
</$parameters>
|
||||
</$value>
|
||||
</$fill>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
@ -7,9 +7,9 @@ title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$transclude $tiddler='TiddlerOne' one='Ferret'>
|
||||
<$value $name="content">
|
||||
<$fill $name="content">
|
||||
Hippopotamus
|
||||
</$value>
|
||||
</$fill>
|
||||
</$transclude>
|
||||
+
|
||||
title: TiddlerOne
|
||||
|
Loading…
Reference in New Issue
Block a user