Jump to content

Topic on Extension talk:MobileDetect/Archive 2

Parser function example

4
Josepablovega (talkcontribs)

could you please provide an example on the extension page like the one for the tags? I get raw code on my phone when using #mobileonly with nested templates, but it does work with #nomobile.

Thanks in advance!

WikiForMen (talkcontribs)

I did a fork of this extension

and a test wiki with examples:

Account: Guest, PW: WikiForMen

Version 2.1 of this extension converted <mobileonly>stuff</mobileonly> into something like <div>stuff</div>.

Version 2.2 of this extension converted <mobileonly>stuff</mobileonly> into something like <span>stuff</span>.

In my fork (version 3.0) it works as I think it should.

See the corresponding examples. (Pay special attention to test 6.)--WikiForMen (talk) 19:15, 26 December 2022 (UTC)

Josepablovega (talkcontribs)

Thanks! With the 3.0 there are no parser functions installed, but the tags are working for me. Thank you again!

WikiForMen (talkcontribs)

In the fork (version 3.0) parser functions ARE installed but work in a different way. ;-)

  1. Version 2.1
    The parser functions convert
    • <mobileonly>stuff</mobileonly> into something like <div class="mobileonly">stuff</div>, which becomes <div style="display: none;">stuff</div>.
    • <nomobile>stuff</nomobile> into something like <div class="nomobile">stuff</div>, which becomes <div style="">stuff</div>.
    and vice versa.
  2. Version 2.2
    The parser functions convert
    • <mobileonly>stuff</mobileonly> into something like <span class="mobileonly">stuff</span>, which becomes <span style="display: none;">stuff</span>.
    • <nomobile>stuff</nomobile> into something like <span class="nomobile">stuff</span>, which becomes <span style="">stuff</span>.
    and vice versa.
  3. Version 3.0 (fork)
    The parser functions removes from
    • <mobileonly>mobile stuff</mobileonly> the tag AND the "mobile stuff": .
    • <nomobile>desktop stuff</nomobile> only the tag and shows the "desktop stuff": desktop stuff.
    and vice versa:
    • <mobileonly>mobile stuff</mobileonly> only the tag and shows the "mobile stuff": mobile stuff.
    • <nomobile>desktop stuff</nomobile> the tag AND the "desktop stuff": .

And in my humble opinion, the parser functions have to work this way and not with the css "gimmiks" of the traditional extension versions.--WikiForMen (talk) 00:41, 27 December 2022 (UTC)

Reply to "Parser function example"