Template:Escape

From imedwiki
Jump to navigation Jump to search
Template documentation[view] [edit] [history] [purge]

Template:Context

Lua error in Module:Lua_banner at line 113: attempt to index field 'edit' (a nil value).

Usage

While primarily intended for use by other Lua modules, it can provide an alternative to multiple <nowiki>...</nowiki> tags when part of the desired output should be executed.

For example, {{demo}} normally requires the demonstrated template to be wrapped in <nowiki>...</nowiki>. 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 Script error: No such module "Escape". is shown inside the <pre>...</pre> tags.

Code Result
{{demo
|<!--not escaped: -->{{escape | mode = kill 
  | char=; 
  | {*{#invoke:Escape ; main ; mode {{=}} kill ;
<!--unescaped:-->{{#invoke:Escape/testcases|test_string2}}<br>; { }*} 
  | * 
  | {{!}} }}
}}
Script error: No such module "Escape".

Script error: No such module "Escape".

Note how the * character, used to break up the {{ to prevent execution, is removed and how the ; character is replaced by |.

Non-execution

After removal of the escape chars, the returned text is inert; i.e. not executed even without <pre>...</pre>. (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:

Script error: No such module "Escape".

Examples

Script error: No such module "Escape".

This template is based (in parts) on the Template:Escape from the free encyclopedia wikipedia and is licensed under GNU license for free documentation and the Creative Commons Attribution/Share Alike. On wikipedia there is a List of authors accessible. More about importing from wikipedia on page Imedwiki:Importing from wikipedia.