Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a22f29c408a16483

Jump to content

Module talk:DemoTemplate

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
(Redirected from Module talk:DemoTemplate/doc)
Latest comment: 11 years ago by SiBr4 in topic Doesn't preserve order of parameters

Doesn't preserve outer spacing

[edit]

See how it doesn't preserve outer spaces around " two inner spaces ". Is that the way we want it to behave? Or is it just the MediaWiki software?

{{#invoke:DemoTemplate|template usage|pattern= two inner spaces }} {{template usage|pattern=two inner spaces}} Testing two inner spaces on this page Thanks. CpiralCpiral 08:43, 24 June 2015 (UTC)Reply

All templates do that. Whitespace at the start and end is stripped in all named and explicitly numbered parameters, but not in unnamed ones:
  • "{{echo| abc }}" " abc "
  • "{{echo|1= abc }}" "abc"
  • "{{#invoke:DemoTemplate|echo| abc }}" "{{1x| abc }} abc "
  • "{{#invoke:DemoTemplate|echo|1= abc }}" "{{1x|abc}} abc"
Since whitespace is stripped before a parameter is passed into a module/template, nothing can be done within this module, but whitespace can be kept by adding <nowiki/> when using it:
  • "{{echo|1=<nowiki/> abc <nowiki/>}}" " abc "
  • "{{#invoke:DemoTemplate|echo|1=<nowiki/> abc <nowiki/>}}" "{{1x|'"`UNIQ--nowiki-00000002-QINU`"' abc '"`UNIQ--nowiki-00000003-QINU`"'}} abc "
SiBr4 (talk) 15:28, 24 June 2015 (UTC)Reply

Doesn't preserve order of parameters

[edit]

{{#invoke:DemoTemplate|Val|11|p=$|upl=acre}} {{Val|11|upl=acre|p=$}} $11/acre CpiralCpiral 23:16, 19 July 2015 (UTC)Reply

@Cpiral: This is a result of standard behavior of Scribunto/Lua. Parameters are passed into a module as a Lua table, which does not preserve the order of named fields. When looping over named table fields, like this template does, they are therefore evaluated in arbitrary order. Nothing can be done in this module, short of adding a front-end parameter to explicitly specify the list of parameters and their order. SiBr4 (talk) 17:46, 26 July 2015 (UTC)Reply