Friday, June 5, 2009
Sunday, May 17, 2009
The Need for More Lack of Understanding
It's not the same kind of non-understanding which I have in mind. I'm talking about a macro/DSL being able to not understand what is passed to it.
I think it's an important feature for the user to be able to get out of your DSL and back in regular Clojure.
In both Moustache and Enlive, I avoid to give a special meaning to lists (in Clojure you also have vectors, maps and sets), hence lists always denote user-code and are embedded as-is in the macro expansion. (If I really had to use lists for a DSL, I would check a list doesn't start with a special value (eg do or unquote (~) — thanks to MB's comment) before processing it).
That's why in Enlive you can easily add your own selectors step [:p (my-selector-step arg1 arg2)] as long as (my-selector-step arg1 arg2) evaluates to a correct value (here a state machine).
That's also how Moustache supports wrapping another Ring handler or custom route validation.
Wednesday, April 22, 2009
Sanitizing HTML with Enlive
net.cgrand.enlive-html=> (sniptest "<div id=user-data>"You also need to remove most attributes but it's just a demo of something that was impossible with the old Enlive.
[:#user-data] (html-content "code injection<script>alert('boo')</script>")
[:#user-data (but #{:p :br :a :strong :em})] nil)
"<html><body><div id=\"user-data\">code injection</div></body></html>"
By the way, the old Enlive is no more. Long live the new Enlive!
Saturday, April 18, 2009
Make it work, make it right, make it fast
- Make it work
- sort of done: the old Enlive,
- Make it right
- work in progress, the new Enlive,
- Make it fast
- once the "right" branch is merged into master.
See the README file to know what's new and here for an example.
