1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-17 17:59:45 +00:00
TiddlyWiki5/editions/test/tiddlers/tests/data/filters/substitute.tid
Saq Imtiaz 3825e2579f
Adds Text substitution support in widget attributes and new operator (#7526)
* feat: new text substitution support, first pass

* fix: use the widget method instead of evaluating a filter

* revert to earlier implementation that emulates macro syntax

* fix: capitalize comments

* feat: add support for triple backticks for substituted attributes

* docs: added docs for substitute operator

* chore: more docs tweaks

* docs: substituted attributes, refactored docs for widget attributes

* docs: fixed typo

* docs: more examples for substituted attributes

* docs: updated prior documentation on concatenating text and variables

* docs: documentation corrections

* Update editions/tw5.com/tiddlers/filters/examples/substitute Operator (Examples).tid

Co-authored-by: btheado <brian.theado@gmail.com>

---------

Co-authored-by: btheado <brian.theado@gmail.com>
2023-06-24 14:57:15 +01:00

40 lines
1.5 KiB
Plaintext

title: Filters/substitute
description: Test substitute operator
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: substitute filter data 1
tags: Hello There [[Welcome to TiddlyWiki]] GettingStarted
TiddlyWiki
+
title: substitute filter data 2
The output of the filter `[[substitute filter data 1]tags[]]` is ${[[substitute filter data 1]tags[]]}$.
+
title: substitute filter data 3
Welcome to $(projectname)$ $1$ $2$ $3$. Tiddlers starting with `substitute`: ${[prefix[substitute]format:titlelist[]join[ ]]}$.
+
title: Output
\whitespace trim
<$let projectname="TiddlyWiki">
(<$text text={{{ [[]substitute[]] }}}/>)
(<$text text={{{ [[Hello There, welcome to $TiddlyWiki$]substitute[]] }}}/>)
(<$text text={{{ [[Welcome to $(projectname)$]substitute[]] }}}/>)
(<$text text={{{ [[Welcome to $(projectname)$ $1$]substitute[today]] }}}/>)
(<$text text={{{ [[This is not a valid embedded filter ${ hello )$]substitute[]] }}}/>)
(<$text text={{{ [{substitute filter data 2}substitute[]] }}}/>)
(<$text text={{{ [{substitute filter data 3}substitute[every],[day]] }}}/>)
</$let>
+
title: ExpectedResult
<p>()
(Hello There, welcome to $TiddlyWiki$)
(Welcome to TiddlyWiki)
(Welcome to TiddlyWiki today)
(This is not a valid embedded filter ${ hello )$)
(The output of the filter `[[substitute filter data 1]tags[]]` is Hello.)
(Welcome to TiddlyWiki every day $3$. Tiddlers starting with `substitute`: [[substitute filter data 1]] [[substitute filter data 2]] [[substitute filter data 3]].)</p>