Skip to content
Carl Calderon edited this page Jun 15, 2013 · 1 revision

One neat feature with liten are the easy-to-use variables. Variables may be defined as either global or local pending on where you place them.

Any variable placed in the lowest indentation level (0) will be global. This include variables defined in imports too.

Local variables can be set anywhere and will only be accessible from within the current scope and it's children. Scopes may be tags or mixins.

Input:

$global_variable = "World"

=myMixin($parameter, $name)
    $a_local_var = "variable from mixin"
    h1:"$parameter $name"
    h2:"I am from mixin: $global_variable"
    h3:"I am local: $a_local_var"
    p
        h1:"I am also local: $a_local_var"

h1:"I am from global: $global_variable"
section
    +myMixin("Hello", "Charlie")
h2:"I cannot be found: $a_local_var"

Output:

<h1>I am from global: World</h1>
<section>
  <h1>Hello Charlie</h1>
  <h2>I am from mixin: World</h2>
  <h3>I am local: variable from mixin</h3>
  <p>
    <h1>I am also local: variable from mixin</h1>
  </p>
</section>
<h2>I cannot be found: undefined</h2>
Clone this wiki locally