Skip to content
cgrand edited this page Sep 13, 2010 · 6 revisions

auto/magic/smart/easy templates

The goal is to have data-driven templates. I’m concerned about data injection risks.

I was thinking of something like (deftemplate a-smart-tmpl [data] (inject data keys-whitelist key-to-selectorfn)) (last two args being optional).

But David Nolen also has an interesting idea (and prototype) of html-driven smart templates.

Templates and snippets composition through Ring middlewares

TODO: Write some examples.

Optimizing selectors

Several ideas:

  • make common selector-steps (tag=, id=, has-class) fail faster
  • switch to table-driven automata
  • preselection for static selectors

Fragment transformations (DONE)

See this conversation

(deftemplate name src [coll]
  {[:h2] [:p]} (clone-for [{:keys [heading content]}]
                 [:h2] (content title)
                 [:p] (content text))) 

is the enlivened version of:

{% for x in coll %}
<h2>{{ x.heading }}</h2>
<p>{{ x.content }}</p>
{% endfor %]