Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Template:Code"

From Roll20 Wiki

Jump to: navigation, search
m (fix linebreak)
m (remove extra input conditions, change text to red)
Line 1: Line 1:
<includeonly>{{#if: {{{3|}}} ||<code style="margin:0">{{{1}}}</code>}}{{#if: {{{2|}}} | <br>}}</includeonly><noinclude>
+
<includeonly><code style="margin:0;color:red;">{{{1}}}</code>}}</includeonly><noinclude>
 +
 
 +
''Ex.'''
 +
 
 +
You can roll it as {{code|/r 1d6+4}}, or as {{code|/roll 1d6+4}}
 +
 
 +
<pre>{{code|r/ 1d6+4}}</pre>
 +
 
 +
''Ex2.'''
 +
 
 +
{{code|<nowiki>{{roll=[[1d6+4]]}}</nowiki>}}
 +
 
 +
<pre>{{code|<nowiki>{{roll=[[1d6+4]]}}</nowiki>}}</pre>
 +
 
 
{{documentation}}
 
{{documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 20:15, 13 November 2020


Ex.'

You can roll it as /r 1d6+4, or as /roll 1d6+4
{{code|r/ 1d6+4}}

Ex2.'

{{roll=[[1d6+4]]}}

{{code|{{roll=[[1d6+4]]}}}}
[view] [edit] [history] [purge] Documentation icon Template documentation

{{code}} is a shorthand to more easily write inline code and highlight variables on the wiki. {{c}} is an even smaller shorthand. For more complex content you'll still likely need to use <code>+<nowiki>-elements, as some special characters causes problem with the template that doesn't happen when using <code>+<nowiki>.

There have been attempt to make the template more robust against this, but seems there is no simple way to put a template variable inside a nowiki element, as anything inside gets ignored.

See: Displaying Macros and Code for details.

Example 1.

any words before /r 1d6+4, or words, /roll 1d6+4

any words before {{code|/r 1d6+4}}, or words, {{c|/roll 1d6+4}}

Example 2.

You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{title=@{character_name} }} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: Inline roll [[1d6+4]] would usually turn into a wiki link

You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name} }}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|Inline roll [[1d6+4]] would usually turn into a wiki link }}

Example 3.

Any text that contains |(pipe) or =(equal sign) need to be escaped with nowiki elements, making use of the template

<input type="text" name="attr_class" value="fighter" >

{{code|<input type="text" name="attr_class" value="fighter" >}}