Keyword with dot(s) #2106
-
Hi, I'm currently trying to mimic Hiccup in Hy. It compiles expressions to HTML (for example It provides a shortcut for providing classes and ids directly in the tag name, i.e. the previous example can be written as
I'm understanding that it conflicts with the attribute access mechanism... What could be a solution to this? Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
this is currently a limitation of the parser. @scauligi is currently doing a full rewrite of the parser that would give us proper support for compile time reader macros and could also potentially give us the flexibility to fix this as well and its already an open issue (see #2096). until then though, you will likely not be able to implement the keyword sugar for class/ids that hiccup provides unless you want to also allow/switch to strings as the tag name (i.e. As an aside, using keywords as dictionary keys in Hy is generally discouraged since Hy is much more closely related to python than clojure is to java and since keywords are used for kwargs such that this is true (dict :class "my-class") ; => {"class" "my-class"}
(:class (dict :class "my-class")) ; => "my-class" |
Beta Was this translation helpful? Give feedback.
this is currently a limitation of the parser. @scauligi is currently doing a full rewrite of the parser that would give us proper support for compile time reader macros and could also potentially give us the flexibility to fix this as well and its already an open issue (see #2096). until then though, you will likely not be able to implement the keyword sugar for class/ids that hiccup provides unless you want to also allow/switch to strings as the tag name (i.e.
["div.my-class#my-id" ...]
which is what i'd probably do) or stick with the explicit dict passing.As an aside, using keywords as dictionary keys in Hy is generally discouraged since Hy is much more closely related to python than c…