clojure - Variable HTML template in Enlive -


i'm trying find 'enlivonic' way of defining function perform transformation on parameterised html template.

in other words, how define defsnippet takes template argument?

i looked @ at, snippet , transformation, i'm little lost in macros :-(

if have transformation, want feed different templates, try:

(defn multi-template [t]     (template t [h1 h2]          [:h1] (content h1)          [:h2] (content h2))) 

this function, when called html template return function takes h1 , h2 arguments , substitutes them given template. call follows:

((multi-template "your-template.html") "heading 1 content" "heading 2 content") 

i used similar when had number of different picture gallery designs templates , wanted switch between dynamically.

note: dynamically creates template each time, whereas deftemplate macro calls template once @ compile time. if slow, there things can optimise (see clojure, enlive, multi-site)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -