zambal / eml

Library for writing and manipulating (html) markup in Elixir.
Other
116 stars 14 forks source link

Support keyword lists without braces for deftags #6

Closed chrismccord closed 9 years ago

chrismccord commented 10 years ago

What are your thoughts on supporting keyword lists to tags without requiring explicit brackets? This would require defining an additional deftag match since do just becomes another key/value pair within the options, but at first glance the additional code would be minimal and would would provide a cleaner markup structure, i.e.:

The win is pretty small, but I'd much prefer to write something like this if possible. Thoughts?

html do
  head class: "head" do
    meta charset: "UTF-8"
  end
  body do
    article id: "main-content" do
      section class: ["intro", "article"] do
        h3 "Hello world"
      end
      section class: ["conclusion", "article"] do
        "TODO"
      end
    end
  end
end
zambal commented 10 years ago

Hi Chris,

This is related to the issue Josh reported here #1 . See my last comment for my thoughts about this. However, I certainly agree that the resulting markup looks cleaner. Since your the second person asking for this and records will be replaced by structs in Elixir (see my comment in #1 why this is relevant), I'll have a look to see if I can implement your request this weekend.

zambal commented 9 years ago

I just released a version of Eml that supports most of your example. The only thing that's not possible with the current version of Eml is writing:

h3 "Hello World"

as you now need to write:

h3 [], "Hello World"

Reason is that I'm still not sure if it would be a good idea to let the first argument of the markup macro's dispatch on argument type.