Hash :
36a5fa0e
Author :
Date :
2019-06-30T04:19:54
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<h2>Comments</h2>
<pre><code>$foo[bar] # Some comment</code></pre>
<h2>Variables and functions</h2>
<pre><code>@navigation[]
$sections[^table::load[sections.cfg]]
$sections.uri</code></pre>
<h2>Literals</h2>
<pre><code>$foo(3+$bar)
^switch[$sMode]{
^case[def]{$result(true)}
}
^if(in "/news/"){}</code></pre>
<h2>Escape sequences</h2>
<pre><code>^^
^"
^;</code></pre>
<h2>Embedded in markup</h2>
<pre><code><nav>
<ul>
^sections.menu{
<li>
<a href="$sections.uri">$sections.name</a>
</li>
}
</ul>
</nav></code></pre>
<h2>Full example</h2>
<pre><code>@CLASS
MyTable
@create[uParam]
^switch[$uParam.CLASS_NAME]{
^case[string;void]{$t[^table::create{$uParam}]}
^case[table;MyTable]{$t[^table::create[$uParam]]}
^case[DEFAULT]{^throw[MyTable;Unsupported type $uParam.CLASS_NAME]}
}
# method will return value in different calling contexts
@GET[sMode]
^switch[$sMode]{
^case[table]{$result[$t]}
^case[bool]{$result($t!=0)}
^case[def]{$result(true)}
^case[expression;double]{$result($t)}
^case[DEFAULT]{^throw[MyTable;Unsupported mode '$sMode']}
}
# method will handle access to the "columns"
@GET_DEFAULT[sName]
$result[$t.$sName]
# wrappers for all existing methods are required
@count[]
^t.count[]
@menu[jCode;sSeparator]
^t.menu{$jCode}[$sSeparator]
# new functionality
@remove[iOffset;iLimit]
$iLimit(^iLimit.int(0))
$t[^t.select(^t.offset[]<$iOffset || ^t.offset[]>=$iOffset+$iLimit)]</code></pre>