Template:Sandbox: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (bug in switch)
(reorganize)
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>
<noinclude>
Often you need to test an idea for a template, so try it out here.
Many times you may want to just 'test' an idea for a template, I haven't found a sensible way of fully testing templates by themselves (as they will not get included in the ''edited'' version, but rather the ''saved'' version).


: I haven't found a sensible way of fully testing templates by themselves (as they will not get included in the ''edited'' version, but rather the ''saved'' version). -- [[User:Xavi]]
The idea of this [[Template:Sandbox]] is to have that, a simple testing zone that will not interfere with others and avoid leaving a trail of botched attempts.


The idea of this {{tl|Sandbox}} page is to have that, a simple testing template that will not interfere with others and avoid leaving a trail of botched attempts.
Please leave this comment/text for others to read.
'''See Also''' http://meta.wikimedia.org/wiki/Help:Template
[[Category:Template]]


If you try out the template here, you have to save the template and then preview to see how it works. You can instead edit [[Test sandbox template]].
: <big>'''Testing: Missing translation<strike></strike>'''</big>


'''See Also''' http://meta.wikimedia.org/wiki/Help:Template
</noinclude>
[[Category:Template]]
{{#switch:{{lc:{{{2|{{{action|}}}}}}}}
|<!-- include action --> include={{:{{{page|{{#rel2abs:..}}}}}}}
|<!-- redirect action --> redirect
|<!-- missing action --> #default=#REDIRECT [[{{{page|{{#rel2abs:..}}}}}]]
}}


''Please leave this comment/text above for others to read.''
[[Category:Missing translation|{{PAGENAME}}]]
----
[[Category:Missing translation lang-{{{lang|{{{1}}}}}}|{{PAGENAME}}]]


: <big>'''Testing: subpage parsing'''</big>


; Goal
'''What is the result of:'''
: Given "Feature roadmap/Name of feature", return "Name of feature"
<tt><nowiki>{{#rel2abs:..}}</nowiki>? [{{#rel2abs:..}}]</tt>
: Given "Just a title", return "Just a title"
<tt><nowiki>{{{page|{{#rel2abs:..}}}}}</nowiki>? [{{{page|{{#rel2abs:..}}}}}]</tt>
<tt><nowiki>{{lc:{{{2|{{{action|}}}}}}}}</nowiki>? [{{lc:{{{2|{{{action|}}}}}}}}]</tt>
<tt><nowiki>default=#REDIRECT [[{{{page|{{#rel2abs:..}}}}}]]</nowiki>? [default=#REDIRECT [[{{{page|{{#rel2abs:..}}}}}]]]</tt>
<noinclude>


</noinclude>
== Usage ==
{{#sub:
{{{1}}} |
{{#if: {{#pos:{{{1}}}|/}} |
{{#expr: {{#pos:{{{1}}}|/}} + 1}} |
{{#pos:{{{1}}}|/}}
}}
}}


pos={{#pos:{{{1}}}|/}}
<nowiki>{{</nowiki>{{PAGENAME}}
iftest={{#if: {{#pos:{{{1}}}|/}} |
| lang = &lt;!-- UNNAMED #1 -- language code of the missing translation (see [[Translating]] for codes) --&gt;
yes |
| ''action'' = &lt;!-- UNNAMED #2 -- OPTIONAL &mdash; what to do. Default is to REDIRECT to the base ''page''. --&gt;
no
| ''page'' = &lt;!-- OPTIONAL &mdash; the page name (sans enclosing ''[[]]'') to include or redirect to --&gt;
}}
<nowiki>}}</nowiki>

== Sample ==

The following are all equivalents, as they all generate a <tt>REDIRECT</tt> directive to the upper level
<nowiki>{{</nowiki>Missing translation|es<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|redirect<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|action=redirect<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|action=redirect|page=Foo<nowiki>}}</nowiki> # assuming the including page is <tt><nowiki>[[Foo/subpage]]</nowiki></tt>

If instead of <tt>REDIRECT</tt>ing you want to include the ''parent'' page, the following are equivalent:
<nowiki>{{</nowiki>Missing translation|es|include<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|include<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|action=include<nowiki>}}</nowiki>
<nowiki>{{</nowiki>Missing translation|lang=es|action=include|page=Foo<nowiki>}}</nowiki> # assuming the including page is <tt><nowiki>[[Foo/subpage]]</nowiki></tt>
# This would include the <tt><nowiki>[[Bar]]</nowiki></tt> page regardless of what the including page is.
<nowiki>{{</nowiki>Missing translation|lang=es|action=include|page=Bar<nowiki>}}</nowiki>


[[Category:Template|{{PAGENAME}}]]
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
</noinclude>

Latest revision as of 01:31, 16 March 2009

Often you need to test an idea for a template, so try it out here.

I haven't found a sensible way of fully testing templates by themselves (as they will not get included in the edited version, but rather the saved version). -- User:Xavi

The idea of this {{Sandbox}} page is to have that, a simple testing template that will not interfere with others and avoid leaving a trail of botched attempts.

If you try out the template here, you have to save the template and then preview to see how it works. You can instead edit Test sandbox template.

See Also http://meta.wikimedia.org/wiki/Help:Template

Please leave this comment/text above for others to read.


Testing: subpage parsing
Goal
Given "Feature roadmap/Name of feature", return "Name of feature"
Given "Just a title", return "Just a title"


{{#sub:

 {{{1}}} |
 Expression error: Unrecognized punctuation character "{".

}}

pos={{#pos:{{{1}}}|/}} iftest=yes