weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 174 forks source link

Export the `normalize-element` API #149

Open johnmcconnell opened 6 years ago

johnmcconnell commented 6 years ago

Hi,

I have the following use case:

Given some complex hiccup structure, I would like to dynamically append classes to children of the hiccup element in a parent function. I would like an API like the following.

For example,

(:require [hiccup.compiler :as c])

(def current-hiccup (complex-hiccup-structure))

(def wanted-hiccup
  (let [[tag attrs children] (c/normalize-element current-hiccup)]
    [tag attrs (map (partial add-class "child-class") current-hiccup)])))  

I noticed normalize-element is in the compilier namespace: https://github.com/weavejester/hiccup/blob/master/src/hiccup/compiler.clj#L87 but that is not documented. Can we document that namespace?

weavejester commented 6 years ago

I don't want to make the compiler namespace entirely public, but exposing normalize-element, perhaps as part of hiccup.util is a possibility. I'll need to consider it.

johnmcconnell commented 6 years ago

Cool!