jsguy / mithril.sugartags

Sugar for mithril templating system
MIT License
20 stars 1 forks source link

tag expressiveness #1

Closed icylace closed 10 years ago

icylace commented 10 years ago

Is there a sugar tag equivalent for elements that have static attributes? For example:

m("a#google.external[href='http://google.com']", "Google");

As I understand it, when using the m function, using a JavaScript object to set attributes is meant for dynamic attributes.

jsguy commented 10 years ago

It would be this:

A({ id: "google", class: "external", href: "http://google.com"}, "Google");

There should be no performance issues, as using a string, (as in your example), would mean mithril is parsing it first. I'd say this is more readable, and (most likely) better performance, win/win!

What do you reckon?

icylace commented 10 years ago

Okay, makes sense !