1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 09:30:28 +00:00

Merge branch 'master' into parameterised-transclusions

This commit is contained in:
jeremy@jermolene.com 2023-03-12 16:19:30 +00:00
commit f9751f19b6
13 changed files with 90 additions and 35 deletions

View File

@ -107,7 +107,7 @@ function diffPartsToChars(text1,text2,mode) {
var lineEnd = -1;
var lineArrayLength = lineArray.length,
regexpResult;
const searchRegexp = /\W+/g;
var searchRegexp = /\W+/g;
while(lineEnd < text.length - 1) {
if(mode === "words") {
regexpResult = searchRegexp.exec(text);

View File

@ -53,7 +53,9 @@ LetWidget.prototype.computeAttributes = function() {
name = attribute.name;
// Now that it's prepped, we're allowed to look this variable up
// when defining later variables
if(value !== undefined) {
self.currentValueFor[name] = value;
}
});
// Run through again, setting variables and looking for differences
$tw.utils.each(this.currentValueFor,function(value,name) {
@ -74,9 +76,7 @@ LetWidget.prototype.getVariableInfo = function(name,options) {
text: this.currentValueFor[name]
};
}
return Widget.prototype.getVariableInfo.call(this,name,$tw.utils.extend(Object.create(null),options,{
defaultValue: ""
}));
return Widget.prototype.getVariableInfo.call(this,name,options);
};
/*

View File

@ -6,7 +6,7 @@ description: {{$:/language/Buttons/NewHere/Hint}}
\whitespace trim
\define newHereActions()
\whitespace trim
<$set name="tags" filter="[<currentTiddler>] [{$:/config/NewTiddler/Tags}]">
<$set name="tags" filter="[<currentTiddler>] [enlist{$:/config/NewTiddler/Tags}]">
<$action-sendmessage $message="tm-new-tiddler" tags=<<tags>>/>
</$set>
\end

View File

@ -0,0 +1,15 @@
title: Widgets/LetWidgetSelfReferences
description: Test let widget self references
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$let default={{{ [[default]is[variable]then[aa]else[bb]] }}} >
<<default>>
</$let>
+
title: ExpectedResult
<p>bb</p>

View File

@ -0,0 +1,15 @@
title: Widgets/LetWidgetUndefinedVariable
description: Test let widget undefined variable
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$let test1=<<test>> test2={{{ [<test1>] }}}>
<<test2>>
</$let>
+
title: ExpectedResult
<p></p>

View File

@ -8,4 +8,4 @@ A JSON tiddler is a [[data tiddler|DataTiddlers]] containing a [[JSON|JavaScript
Its [[ContentType]] is `application/json`.
The [[history list|$:/HistoryList]] is an of a JSON tiddler.
The [[history list|$:/HistoryList]] is an example of a JSON tiddler.

View File

@ -1,9 +1,22 @@
created: 20150118134611000
modified: 20150124201839000
modified: 20230310154010278
myfield:
tags: [[get Operator]] [[Operator Examples]]
title: get Operator (Examples)
type: text/vnd.tiddlywiki
<<.operator-example 1 "[all[current]get[draft.of]]" "the title of the tiddler of which the current tiddler is a draft">>
<<.operator-example 2 "[get[tags]]">>
<<.operator-example 3 "[each[tags]get[tags]]">>
<<.operator-example 2 "[get[tags]]" "returns the tags of all tiddlers without de-duplication">>
<<.operator-example 3 "[get[tags]unique[]]" "returns the tags of all tiddlers with de-duplication">>
<<.tip """If a data tiddler contains a field with an empty value, the empty string is not appended to the results.""">>
<<.operator-example 4 "[all[current]get[myfield]]" "the empty value of field <<.field myfield>> is not returned by the <<.olink get>> operator">>
<<.operator-example 5 "[all[current]] :filter[has:field[myfield]] :map[get[myfield]]" "also returns the empty string">>
The above example works by first using the [[Filter Filter Run Prefix]] to only select titles that have the field <<.field myfield>> and then using the [[Map Filter Run Prefix]] to replace those titles with their value of that field. The [[Map Filter Run Prefix]] outputs an empty string when its filter run returns an empty [[selection|Title Selection]].
<<.operator-example 6 "[all[tiddlers]] :filter[get[created]compare:date:lt{HelloThere!!created}]" "return all tiddlers that are older than [[HelloThere]]">>
The above example demonstrates two different ways of accessing field values in filters: Use <<.olink get>> when the title is not known in advance as with the [[Filter Filter Run Prefix]] where <<.var currentTiddler>> is set to the current input title. Use a [[TextReference]] as an indirect [[Filter Parameter]] when the title is known.

View File

@ -1,8 +1,19 @@
created: 20150203140000000
modified: 20170608150301791
modified: 20230309180501044
tags: [[getindex Operator]] [[Operator Examples]]
title: getindex Operator (Examples)
type: text/vnd.tiddlywiki
<<.operator-example 1 "[[$:/palettes/Vanilla]getindex[background]]" "returns the value at index ''background'' of the [[DataTiddler|DataTiddlers]] [[$:/palettes/Vanilla]]">>
<<.operator-example 2 "[all[shadows+tiddlers]tag[$:/tags/Palette]getindex[background]]" "returns all background colors defined in any of the ColourPalettes">>
<<.operator-example 1 "[[$:/palettes/Vanilla]getindex[background]]" "returns the value of property <<.value background>> of the [[DataTiddler|DataTiddlers]] [[$:/palettes/Vanilla]]">>
<<.operator-example 2 "[all[shadows+tiddlers]tag[$:/tags/Palette]getindex[background]]" "returns all background colors defined in any of the ColourPalettes (notice the duplicates in the resulting list)">>
<<.tip """If a data tiddler contains a property with an empty value, the empty string is not appended to the results.""">>
<<.operator-example 3 "[[ListopsData]getindex[DataIndex]]" "the empty value of the property <<.field ~DataIndex>> in [[ListopsData]] is not returned by the <<.olink getindex>> operator">>
<<.operator-example 4 "[[ListopsData]] :filter[has:index[DataIndex]] :map[getindex[DataIndex]]" "also returns the empty string">>
The above example works by first using the [[Filter Filter Run Prefix]] to only select titles that have the property <<.field ~DataIndex>> and then using the [[Map Filter Run Prefix]] to replace those titles with their value of that property. The [[Map Filter Run Prefix]] outputs an empty string when its filter run returns an empty [[selection|Title Selection]].
<<.operator-example 5 "[[$:/palettes/Vanilla]indexes[]] :filter[[$:/palettes/Vanilla]getindex<currentTiddler>count[]compare:number:eq[0]]" "returns those colors in [[$:/palettes/Vanilla]] which are defined, but have no value assigned">>
In the above example, <<.olink count>> is used to check if <<.olink getindex>> returns a result (i.e. the corresponding property has a value) or not.

View File

@ -1,17 +1,17 @@
caption: get
created: 20140426183123179
modified: 20150203185001000
modified: 20230309163844434
op-input: a [[selection of titles|Title Selection]]
op-output: the values of field <<.place F>> in each of the input titles
op-parameter: the name of a [[field|TiddlerFields]]
op-parameter-name: F
op-purpose: select all values of a field in the input titles
tags: [[Filter Operators]] [[Field Operators]]
title: get Operator
type: text/vnd.tiddlywiki
caption: get
op-purpose: select all values of a field in the input titles
op-input: a [[selection of titles|Title Selection]]
op-parameter: the name of a [[field|TiddlerFields]]
op-parameter-name: F
op-output: the values of field <<.place F>> in each of the input titles
Each input title is processed in turn. If the corresponding tiddler contains field <<.place F>>, and the value of this field is not empty, then its value is appended to the output.
Unlike most other [[Filter Operators]], the [[selection|Title Selection]] output by <<.op get>> can contain duplicates. To avoid duplicates, use `each[F]get[F]`.
<<.tip "Unlike most other [[Filter Operators]], the [[selection|Title Selection]] output by <<.op get>> can contain duplicates. To avoid duplicates, use `get[F]unique[]`.">>
<<.operator-examples "get">>

View File

@ -1,17 +1,16 @@
caption: getindex
created: 20150203140000000
modified: 20150203140000000
modified: 20230309163838670
op-input: a [[selection of titles|Title Selection]]
op-output: the values of property <<.place P>> in each of the input titles
op-parameter: the name of a [[property|DataTiddlers]]
op-parameter-name: P
op-purpose: select all values of a data property in the input titles
tags: [[Filter Operators]] [[Field Operators]]
title: getindex Operator
caption: getindex
op-purpose: select all values of a data property in the input titles
<$macrocall $name=".operator-def"
input="a [[selection of titles|Title Selection]]"
parameter="the name of a [[property|DataTiddlers]]"
paramName="P"
output="the values of property <<.place P>> in each of the input titles"
/>
Each input title is processed in turn, and is ignored if it does not denote a [[data tiddler|DataTiddlers]]. If the corresponding tiddler contains property <<.place P>>, and the value of this property is not empty, then its value is appended to the output.
Each input title is processed in turn, and is ignored if it does not denote a [[data tiddler|DataTiddlers]]. If the tiddler contains property <<.place P>>, the value of that property is [[dominantly appended|Dominant Append]] to the output.
<<.tip "Unlike most other [[Filter Operators]], the [[selection|Title Selection]] output by <<.op getindex>> can contain duplicates. To avoid duplicates, use `getindex[P]unique[]`.">>
<<.operator-examples "getindex">>

View File

@ -1,9 +1,9 @@
caption: has
created: 20140410103123179
modified: 20190518145446047
modified: 20230306143207920
op-input: a [[selection of titles|Title Selection]]
op-neg-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist<br>''suffix `index`''<br>&raquo; those input tiddlers in which index <<.place F>> does <<.em not>> exist
op-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> has a non-empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> exists
op-neg-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist<br>''suffix `index`''<br>&raquo; those input data tiddlers in which index <<.place F>> does <<.em not>> exist
op-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> has a non-empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> exists<br>''suffix `index`''<br>&raquo; those input data tiddlers in which index <<.place F>> exists
op-parameter: the name of a [[field|TiddlerFields]]<br>''suffix `index`''<br>&raquo; those input tiddlers in which index <<.place F>> exists
op-parameter: the name of a [[field|TiddlerFields]] or, optionally an [[index|TextReference]]
op-parameter-name: F

View File

@ -32,7 +32,7 @@ For example, the items "abc" and "123" can be appended to the field `myfield` us
<$action-listops $field="myfield" $subfilter="abc 123"/>
```
The same can be achieved using the `$filter` attribute and prepending the [[Filter Run]] `[all[current]get[myfield]enlist-input[]]` to the [[Filter Expression]]:
The same can be achieved using the `$filter` attribute and prepending the [[Filter Run]] `[enlist{!!myfield}]` to the [[Filter Expression]]:
```
<$action-listops $field="myfield" $filter="[enlist{!!myfield}] abc 123"/>

View File

@ -525,3 +525,5 @@ Mateusz Wilczek, @mateuszwilczek, 2023/02/16
Andrea Octo, @andrigamerita, 2023/02/24
HuanC Fu, @hffqyd, 2023/03/03
Michelle Saad, @michsa, 2023-03-08