mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-08-19 09:18:56 +00:00
Add tests/examples for transclusion shortcut syntax (#9705)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
caption: Calls
|
||||
created: 20221007130006705
|
||||
modified: 20260125212303316
|
||||
modified: 20260301030947969
|
||||
tags: WikiText Procedures Functions Macros
|
||||
title: Calls
|
||||
type: text/vnd.tiddlywiki
|
||||
@@ -25,6 +25,12 @@ Each parameter value can be enclosed in `'`single quotes`'`, `"`double quotes`"`
|
||||
|
||||
See the discussion about [[parser modes|WikiText parser mode: macro examples]]
|
||||
|
||||
!!! Examples
|
||||
|
||||
<<testcase TestCases/Calls/ProcedureStaticAttributes>>
|
||||
|
||||
<<testcase TestCases/Calls/ProcedureDynamicAttributes>>
|
||||
|
||||
!! Calls with <<.wlink TranscludeWidget>> Widget
|
||||
|
||||
The shortcut syntax expands to the <<.wlink TranscludeWidget>> widget with the `$variable` attribute specifying the name of the procedure to transclude.
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
created: 20260301005951330
|
||||
description: Procedure calls with dynamic attributes
|
||||
modified: 20260301013907635
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/Calls/ProcedureDynamicAttributes
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
New-style equals sign named parameters support dynamic values
|
||||
+
|
||||
title: Output
|
||||
|
||||
\function f(a) foo [<a>] :and[join[ ]]
|
||||
\procedure p(a1) <$text text=<<a1>>/>
|
||||
|
||||
<$let v="foo 1" v2="foo 3">
|
||||
<<p a1=<<v>>>> -
|
||||
<<p a1=<<f 2>>>> -
|
||||
<<p a1=`$(v2)$`>> -
|
||||
<<p a1={{my tiddler}}>> -
|
||||
<<p a1={{my tiddler!!myfield}}>> -
|
||||
<<p a1={{{ foo 6 :and[join[ ]] }}}>>
|
||||
</$let>
|
||||
+
|
||||
title: my tiddler
|
||||
myfield: foo 5
|
||||
|
||||
foo 4
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>
|
||||
foo 1 -
|
||||
foo 2 -
|
||||
foo 3 -
|
||||
foo 4 -
|
||||
foo 5 -
|
||||
foo 6
|
||||
</p>
|
||||
@@ -0,0 +1,48 @@
|
||||
created: 20260301000418824
|
||||
description: Procedure calls with static attributes
|
||||
modified: 20260301031128810
|
||||
tags: $:/tags/wiki-test-spec
|
||||
title: TestCases/Calls/ProcedureStaticAttributes
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
||||
title: Narrative
|
||||
|
||||
Positional, old style colon named parameters, and new-style equals sign named parameters support static values
|
||||
+
|
||||
title: Output
|
||||
|
||||
\procedure p(a1) <$text text=<<a1>>/>
|
||||
|
||||
<<p foo1>> -
|
||||
<<p a1:foo2>> -
|
||||
<<p a1=foo3>>
|
||||
|
||||
<<p "foo 4">> -
|
||||
<<p a1:"foo 5">> -
|
||||
<<p a1="foo 6">>
|
||||
|
||||
<<p 'foo 7'>> -
|
||||
<<p a1:'foo 8'>> -
|
||||
<<p a1='foo 9'>>
|
||||
|
||||
<<p """foo 10""">> -
|
||||
<<p a1:"""foo 11""">> -
|
||||
<<p a1="""foo 12""">>
|
||||
|
||||
<<p [[foo 13]]>> -
|
||||
<<p a1:[[foo 14]]>> -
|
||||
<<p a1=[[foo 15]]>>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>foo1 -
|
||||
foo2 -
|
||||
foo3</p><p>foo 4 -
|
||||
foo 5 -
|
||||
foo 6</p><p>foo 7 -
|
||||
foo 8 -
|
||||
foo 9</p><p>foo 10 -
|
||||
foo 11 -
|
||||
foo 12</p><p>foo 13 -
|
||||
foo 14 -
|
||||
foo 15</p>
|
||||
Reference in New Issue
Block a user