1 line
4.8 KiB
HTML
1 line
4.8 KiB
HTML
|
<!DOCTYPE HTML><html><head><meta charset="UTF-8"><title>NML | Variables</title><link rel="stylesheet" href="../style.css"></head><body><div class="layout"><input id="navbar-checkbox" class="toggle" type="checkbox" style="display:none" checked><div id="navbar"><ul><li class="navbar-entry"><a href="Getting Started.html">Getting Started</a></li><li class="navbar-entry"><a href="Sections.html">Sections</a></li><li class="navbar-entry-current"><a href="Variables.html">Variables</a></li><li class="navbar-entry"><a href="References.html">References</a></li><li class="navbar-entry"><a href="Imports.html">Imports</a></li><li class="navbar-entry"><a href="Raw.html">Raw</a></li><li class="navbar-entry"><a href="Comments.html">Comments</a></li><li><details><summary class="navbar-category">External Tools</summary><ul><li class="navbar-entry"><a href="Graphviz.html">Graphviz</a></li><li class="navbar-entry"><a href="LaTeX.html">LaTeX</a></li></ul></details></li><li><details><summary class="navbar-category">Blocks</summary><ul><li class="navbar-entry"><a href="Blockquotes.html">Blockquotes</a></li><li class="navbar-entry"><a href="Code.html">Code</a></li><li class="navbar-entry"><a href="Lists.html">Lists</a></li></ul></details></li><li><details><summary class="navbar-category">Lua</summary><ul><li class="navbar-entry"><a href="Lua Basics.html">Lua</a></li></ul></details></li><li><details><summary class="navbar-category">Styles</summary><ul><li class="navbar-entry"><a href="Basic Styles.html">Basic</a></li><li class="navbar-entry"><a href="Basic Layouts.html">Layouts</a></li><li class="navbar-entry"><a href="User-Defined Styles.html">User-Defined</a></li></ul></details></li></ul></div><label for="navbar-checkbox" class="navbar-checkbox-label">☰</label><div class="content"><div class="toc"><span>Table of Content</span><ol><li value="1"><a href="#Variable_definition">Variable definition</a></li><li value="2"><a href="#Variable_substitution">Variable substitution</a></li></div><h1 id="Variable_definition">1. Variable definition <a class="section-link" href="#Variable_definition">🔗 </a> </h1><p>In NML you can defines variables and call them later.</p><p>Currently, two types of variables are supported:</p><ul><li><b>Text variables</b>: Just simple text</li><li><b>Path variables</b>: Path aware variables, that will display an error if the path doesn't exist or is not accessible</li></ul><p>To define a variable use the following syntax:</p><div class="code-block"><div class="code-block-content"><table cellspacing="0"><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">@var = value</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">:: Text variable</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">@'my_file = ./pic.png</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">:: Path variable</span></pre></td></tr></table></div></div><p>Variable names cannot contain <em>%</em> or <em>=</em>. However variables values can span across multiple lines:</p><div class="code-block"><div class="code-block-content"><table cellspacing="0"><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">@var = A\</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">B</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">:: var == "AB"</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">@var = A</span><span style="color:#96b5b4;">\\</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">B</span></pre></td></tr><tr><td class="code-block-line"><pre><span style="color:#c0c5ce;">:: var == "A\nB"</span></pre></td></tr></table></div></div><p>Using a single <em>\</em>'s will ignore the following newline, using two <em>\\</em>'s will keep the newline.</p><h1 id="Variable_substitution">2. Variable substitution <a class="section-link" href="#Variable_substitution"
|