kumarshantanu / basil

A general purpose template library for Clojure and ClojureScript
9 stars 1 forks source link

Implement nesting #4

Open kumarshantanu opened 11 years ago

kumarshantanu commented 11 years ago

(Note: This is complex for the user. See #9 directives as an alternative.)

Implement nesting as follows:

placement slot begin slot end
nesting-begin <%# %>
nesting-contd <%% %>
nesting-end <%/ %>

Notes:

  1. Independent <%..%> slots are to be compiled as-it-is.
  2. Matching nested slots (markers shown above) are to be compiled into a single block.
  3. Nesting depth may be arbitrary as long as the template is well formed.

For the mustache template below

{{#items}}
  {{#first}}
    <li><strong>{{name}}</strong></li>
  {{/first}}
  {{#link}}
    <li><a href="{{url}}">{{name}}</a></li>
  {{/link}}
{{/items}}

the equivalent Basil template would look like as follows:

<%# (in items ; explodes each element in 'items', concats all form results
      (in first %>
        <li><strong><%name%></strong></li><%% )
      (in link %>
        <li><a href="<%url%>"><%name%></a></li><%/ )) %>