Closed pauldorman closed 11 years ago
Thanks for the patch, but equivalent functionality has already been written in the refactor branch.
Can I ask why the "refactor" branch hasn't progressed in the past year? If there's a to-do list I'd be pleased to have a crack at it.
The refactor branch has one major disadvantage over version 1.0: it's not nearly as performant. Version 1.0 of Hiccup pre-compiles the HTML directly into strings, which makes it very fast, but also much less flexible than an approach that produces a data structure instead.
I'm more or less resigned to this trade-off now, but that's the reason I've been delaying merging the branch. It's also been a low-priority itch for me; after all, Hiccup 1.0 works perfectly well.
To an extent the speed of Hiccup 1.0 is also illusionary. The functions in hiccup.form
are not pre-compiled, and it's easy to produce code that the compiler cannot optimize ahead of time, so unless you're being careful one can lose any speed advantages anyway.
In terms of what's left to do... I need to:
hiccup.output
any furtherhiccup.output
into hiccup.output.basic
or something like thathiccup.compiler/return-type
with a more sophisticated optimizer based on core.logic or core.matcher.clojure.xml
-style data structures.Interesting. It would also be good to see default HTML safety come out of this, as per:
https://github.com/weavejester/hiccup/issues/5
It's very unfortunate that metadata can't be set on a string.
Hi, this introduces a new "parse" macro to hiccup.core, as well as substantial changes to the compiler. The new macro accepts the same input as the hiccup.core/html macro but produces a nested map data structure instead of strings of HTML, e.g.
There is always a root element represented by a map with a single key and a vector containing the content data:
The "html" macro can take the map produced by parse (or your own functions) and return strings in line with existing behaviour:
The "parse" and "html" macros can be composed and nested freely without adding complexity to the result:
I hope the consistent data structure produced by the "parse" macro will simplify the task of writing functions that manipulate Hiccup forms before they are rendered as HTML strings, and allow for extending Hiccup's core functionality in your own programs.