Skip to content

Instantly share code, notes, and snippets.

@ckirkendall
Created December 1, 2011 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckirkendall/1418965 to your computer and use it in GitHub Desktop.
Save ckirkendall/1418965 to your computer and use it in GitHub Desktop.
(em/defsnippit snippit1 "templates/template1.html" [:tbody :> 'first-child]
[fruit quantity]
[:tr :> 'first-child] (ef/content fruit)
[:tr :> 'last-child] (ef/content (str quantity)))
(em/deftemplate template1 "/templates/template1.html" [fruit-data]
[:#heading1] (ef/content "fruit")
[:thead :tr :> 'last-child] (ef/content "quantity")
[:tbody] (ef/content
(map #(snippit1 % (fruit-data %)) (keys fruit-data))))
(em/defaction action1 []
[:.cool (ef/attr= :foo "false")] (ef/content (template1 {"apple" 5 "pear" 6})))
(em/defsnippit snippit2 "templates/template1.html" ["tbody > *:first-child"]
[fruit quantity]
["tr > *:first-child"] (ef/content fruit)
["tr > *:last-child"] (ef/content (str quantity)))
(em/deftemplate template2 "/templates/template1.html" [fruit-data]
["#heading1"] (ef/content "fruit")
["thead tr > *:last-child"] (ef/content "quantity")
["tbody"] (ef/content
(map #(snippit1 % (fruit-data %)) (keys fruit-data))))
(em/defaction action2 []
[".cool[foo=false]"] (ef/content (template1 {"bannan" 5 "pineapple" 10})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment