Template:Escape
This template uses Lua: |
Usage[edit source]
While primarily intended for use by other Lua modules, it can provide an alternative to multiple TAG tags when part of the desired output should be executed.
For example, {{Demo}} normally requires the demonstrated template to be wrapped in TAG. However, you may want part of the value to be shown in the 'pre' tag to be processed before it reaches {{Demo}}, such as in the example below where the result of {{#invoke:Escape/testcases|test_string2}}
is shown inside the TAG tags.
Code | Result |
---|---|
{{demo
|<!--not escaped: -->{{escape | mode = kill
| char=;
| {*{#invoke:Escape ; main ; mode {{=}} kill ;
<!--unescaped:-->{{#invoke:Escape/testcases|test_string2}}<br>; { }*}
| *
| {{!}} }}
}}
|
{{#invoke:Escape | main | mode = kill | test { test {\{ test, \test, \{,test\ \ \ {\ test test { test, test, {,test |
Note how the *
character, used to break up the {{
to prevent execution, is removed and how the ;
character is replaced by |
.
Non-execution[edit source]
After removal of the escape chars, the returned text is inert; i.e. not executed even without TAG. (The above example is executed only because {{Demo}} forces execution.)
For example, setting |mode=kill
with \{\{done\}\
} as the first parameter and nothing else will simply cause the default escape character \
to be removed:
{{done}}
Examples[edit source]
Original:[edit source]
test { test {\{ test, \test, \{,test\ \ \ {\
Using internal method to remove {
:[edit source]
{{escape|mode=kill|test { test {\{ test, \test, \{,test\ \ \ {\|{}}test test { test, test, {,test \
Using {{Replace}} to remove {
:[edit source]
{{escape|mode=undo|{{replace|{{escape|mode=text|test { test {\{ test, \test, \{,test\ \ \ {\}}|{|}}}}test test { test, test, {,test \
No removal of {
between escape/unescape (escape char not restored):[edit source]
{{escape|mode=undo |{{escape|mode=text|test { test {\{ test, \test, \{,test\ \ \ {\}} }}test { test {{ test, test, {,test {\
Restore to original after escape[edit source]
{{escape|mode=undo |{{escape|mode=text|test { test {\{ test, \test, \{,test\ \ \ {\}} |\ }}test { test {\{ test, \test, \{,test\ \ \ {\
Remove the word test
if not escaped and then place a different escape char in the place of the old escape char (for use by something else):[edit source]
Note: The '%' char is a special in Lua, so use '%%' if that is the desired replacement. Otherwise, just a single char is fine (or a word).
{{escape|mode=kill |test { test {\{ test, \test, \{,test\ \ \ {\ |test |%% }}{ {%{ , %test, %{,% % % {\
External links[edit source]
- Template:Escape at Wikipedia, the free Terran encyclopedia that anyone can edit.
The above documentation is transcluded from Template:Escape/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |