# Tests of Parsoid PFragment Handlers # TODO (T390343): wt2wt/html2wt modes should be enabled in parsoid-compatible !! options parsoid-compatible=wt2html version=2 !! end !! article Template:1x !! text {{{1}}} !! endarticle !! article Foo !! text Define [[Foo]] to avoid a red link !! endarticle !! article FOO !! text #REDIRECT [[Foo]] !! endarticle !! test f1_wt: Basic parser function test !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|bar}} {{#f1_wt:foo|''bar''}} !! html/parsoid
foo bar
foo bar
!! end !! test f1_wt: Nested template for an arg !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|1|{{1x|A}}|2}} !! html/parsoidfoo 1 A 2
!! end !! test f1_wt: Multi-level nesting of templates and parser functions !! options parsoid=wt2html,wt2wt !! wikitext {{#f1_wt:foo|1|{{1x|{{#f1_wt:BAR|A|{{1x|B}}|C}}D}}|{{1x|3}}|4}} !! html/parsoid+integratedfoo 1 BAR A B CD 3 4
!! end !! test f1_wt: Case insensitivity !! options parsoid=wt2html,wt2wt !! wikitext {{#F1_wt:x}} {{#f1_WT:y}} !! html/parsoidx
y
!! end # T391063: the zero-arg form will need to be explicitly permitted as a # "magic variable" in the future. !! test f1_wt_nohash: Test 'nohash' option !! options parsoid=wt2html,wt2wt !! wikitext 0 args: {{f1_wt_nohash}} (no output) 1 arg: {{f1_wt_nohash:foo}} {{#f1_wt_nohash:foo}} !! html/parsoid+standalone0 args: (no output)
1 arg: foo
Parser function implementation for pf_f1_wt_nohash missing in Parsoid.
!! html/parsoid+integrated0 args: (no output)
1 arg: foo
{{#f1_wt_nohash:foo}}
!! end !! test f1_wt_hash: Test magic words which already include the leading hash !! options parsoid=wt2html,wt2wt !! wikitext 0 args: {{#f1_wt_hash}} {{f1_wt_hash:foo}} 1 arg: {{#f1_wt_hash:foo}} !! html/parsoid0 args:
1 arg: foo
!! end !! test f2_if: test basic operation !! options parsoid=wt2html,wt2wt !! wikitext {{#f2_if: |yes|NO}} {{#f2_if:{{1x| }}|yes|NO}} {{#f2_if:{{1x|x}}|'''yes'''|NO}} {{#f2_if: |'''YES'''|NO}} {{#f2_if:NO
NO
yes
NO
yes
!! end !! test f2_if: Verify lazy evaluation of then/else !! options cat parsoid=wt2html,wt2wt !! wikitext {{#f2_if:1|{{1x|[[Category:Foo]]}}|{{1x|[[Category:Bar]]}}}} !! metadata/parsoid cat=Foo sort= !! html/parsoid !! end !! test f3_uc: basic operation !! options parsoid=wt2html,wt2wt !! wikitext {{#f3_uc:lower UPPER}} {{#f3_uc:{{1x|foo}}}} !! html/parsoidLOWER UPPER
FOO
!! end !! test f3_uc: nowiki content should be skipped (not converted to uppercase) !! options parsoid=wt2html,wt2wt !! wikitext {{#f3_uc:prePREinsidePOST
!! end # TODO T390345: content insidePREinsidePOST
!! end !! test f4_return_html: test returning an HTML fragment !! options parsoid=wt2html,wt2wt !! wikitext {{#f4_return_html}} !! html/parsoid+integratedhtml contents
!! end !! test f5_from_nowiki: test retrieving an argument from'''oof''' >b/<pukram>b< ]]htiw[[ tnemugra
!! end # TODO T390345: argument chaining doesn't work yet # Note also that & is decoded, even inside a&
!! end !! test f6_async_return: Test conditionally-asynchronous content (ready case) !! options parsoid=wt2html,wt2wt showflags !! wikitext Content is ready: {{#f6_async_return:ready|Ready!}} !! metadata/parsoid flags=has-async-content !! html/parsoidContent is ready: Ready!
!! end !! test f6_async_return: Test conditionally-asynchronous content (not ready case) !! options parsoid=wt2html,wt2wt showflags !! wikitext Default fallback content: {{#f6_async_return:not ready}} Specified fallback content: {{#f6_async_return:not ready|My own fallback}} !! metadata/parsoid flags=async-not-ready, has-async-content !! html/parsoid+integratedDefault fallback content:
Specified fallback content: My own fallback
!! end !! test f7_kv: simple return !! options parsoid=wt2html !! wikitext {{#f7_kv:foo=bar|bat=baz}} !! html/parsoid+integrated(arguments)
!! end # TODO T390344: named arguments (add back wt2wt mode once fixed) # TODO T390347: argument interpolation !! test f7_kv: ordered argument chaining !! options parsoid=wt2html !! wikitext {{#f1_wt:A|{{#f7_kv:B|C}}|D}} !! html/parsoid+integratedA B C D
!! end !! test f8_countargs: verify zero-arg handling !! options parsoid=wt2html !! wikitext * Zero: {{#f8_countargs}} * One: {{#f8_countargs:}} * One: {{#f8_countargs:one}} * Two: {{#f8_countargs:one|two}} !! html/parsoid+integrated