ckirkendall / kioo

Enlive/Enfocus style templating for Facebook's React and Om in ClojureScript.
Eclipse Public License 1.0
404 stars 39 forks source link

Added a :process-ast option to modify templates at compile time. #65

Closed tdammers closed 8 years ago

tdammers commented 8 years ago

The :process-ast option expects a function that transforms the enlive-style template, right after parsing from HTML. This allows the programmer to inject arbitrary ClojureScript into the template before applying transforms and passing it to the emitter functions. The injection happens at compile time, but the transformation function can inject clojurescript code that will run at runtime.

One use case for this is embedding a minilanguage into text nodes in the HTML templates: the transformation function in this case traverses the template, parsing string nodes and replacing them with suitable clojurescript function calls.

This is in response to issue #64 (Compile Time Transforms), and should be enough to solve my problem.