User:Celierra Darling/Sandbox

From Second Life Wiki
Jump to: navigation, search

Specific Instruction Template

Update: Tests available at /SpecInstr, /Leaf, /Node

I think Template:Specific Instruction would be something like:

{{#ifeq: {{{current|{{{1|}}}}}} | * | {{{3|{{{2|}}}}}} |
 {{#if: {{{target|{{{3|}}}}}} |
  {{#ifeq: {{{current|{{{1|}}}}}} | {{{target|{{{2|}}}}}} | {{{3|}}} | }} |
  {{#if: {{{current|{{{1|}}}}}} | {{{2|}}} | }}
 }} }} 

...but I haven't tested this thoroughly.

I imagine the template would be used in one of these ways:

{{Specific Instruction | {{{A|<noinclude>*</noinclude>}}} | text}}

...which outputs the text if A is defined and non-blank or if the current page is being viewed on its own (e.g. if you're looking at CMake, not some article that calls {{:CMake}}). It outputs nothing otherwise.

{{Specific Instruction | {{{A|*}}} | B | text}}

...which outputs text iff A is the string "B", A is the string "*", or the current page is being viewed on its own. This defaults to showing the message if A is undefined.

{{Specific Instruction | {{{A|<noinclude>*</noinclude>}}} | B | text}}

...the same as above, but defaults to not showing the message if A is undefined.

Also, there will probably need to be a different template designed to test versions (i.e. whether 1.22 < 1.20), using #ifexpr statements.

P.S. I think the noinclude tags are an obfuscatory hack. Does anyone know of a better way to do it?