Helma Logo
main list history
previous version  overview  next version

Version 3 by hannes on 09. December 2005, 12:02

==== Spec

* Macros in skins are marked as (&42; &42;)(* *).
* Macros can contain both named and unnamed parameters, in any combination.
* Named parameters are denoted as name=value, unnamed parameters are denoted as value.
* For string parameter values, single or double quotes are optional unless the value contains whitespace characters.
* Macro parameters wrapped in ( ) are interpreted as nested macros.
* Macro parameters wrappedn in {{ }} are interpreted as nested skins.
* Skins and macros are both implemented as plain JS objects.
* Macro parameters are passed in a way that allows sequential value lookup, sequential name lookup and named lookup:
    var params = {
      values: [],
      names: [],
      byName: {}
    }
* Nested skins and macros are passed to macros as skin and macro objects, respectively. In other words, macro evaluation and skin rendering is up to the containing macro.
* Standard macros such as if/else, foreach, equals, greaterThan are implemented as plain macros in JS.

==== Examples

 (&42;(*
  if (user) {{
    <div>Logged in as (&42; (* user.name &42;)</div>*)</div>
  }} else {{
    <form action="(&42; (* loginUrl &42;)*)"
    <table><tr>
      <td>Name</td><td><input name="name"></td>
      <td>Password</td><td><input type="password" name="password"></td>
    </tr></table>
    </form>
  }}
 &42;)*)


 <h1>(&42; <h1>(* story.title &42;)</h1>*)</h1>
 <div>(&42; <div>(* story.text &42;)</div>*)</div>
 (&42;(*
  if (story.hasComments) {{
  <table>
   (&42; (* foreach comment in (story.comments)
    {{
    <tr>
      <td>(&42; <td>(* encode(comment.title) &42;)</td>*)</td>
      <td>(&42; <td>(* encode(comment.text) &42;)</td>*)</td>
    </tr>
    }}
   &42;)*)
  </table>
  }}
 &42;)*)

     removed
     added