hamlphp / HamlPHP

Yet another Haml to HTML converter written in PHP.
http://hamlphp.github.com/HamlPHP
MIT License
84 stars 15 forks source link

Using () for attributes instead of {} ? #1

Closed matify closed 12 years ago

matify commented 13 years ago

Took me a little while to figure out why the {}'s weren't working. I am wondering if it's coded that way for a specific reason?

sniemela commented 13 years ago

Good catch! Both () and {} should be supported. I will fix this asap. Haml Reference

svallory commented 13 years ago

Actually they doesn't work in the same way. When you use ()s the attributes inside them are pushed to the tag exactly as they were written. Should we keep this behavior or not? I can't see any advantage in the way ()'s work

sniemela commented 13 years ago

We should keep both styles available.

svallory commented 13 years ago

I agree. But the question is: should they behave differently? (like in haml)

sniemela commented 13 years ago

Yes, they should behave the same way.

svallory commented 13 years ago

I have compiled list of requirements for the attributes functionality (from haml documentation). See if you agree with all:

Hash-style Attributes: {}

HTML-style Attributes: ()

HTML5 Custom Data Attributes

Custom data attributes can be used in Haml by using the key data with a Hash value in an attribute hash. Each of the key/value pairs in the Hash will be transformed into a custom data attribute. For example:

%a{href=>"/posts", data => {author_id => 123}} Posts By Author

will render as:

<a data-author_id='123' href='/posts'>Posts By Author</a>
sniemela commented 13 years ago

I agree with you. Are keys written without quotes?

svallory commented 13 years ago

Yeah, they are. I've updated my last comment because I had left some ruby syntax. Now it's all php. I think we shouldn't require the colon (:) before the attribute, but we could allow it and just strip it out. It can be helpful for syntax coloring. There's some open source plugins for various IDEs we can modify.

I already started working on this. I'll let the multiline requirement to the end. We have to decide if the NodeFactory will pull the next line or if the parser will join the lines as needed before passing it to the NodeFactory. I prefer the first one for the cohesion, since NodeFactory has the knowledge of how nodes are written.

machuga commented 12 years ago

Just curious, is this still an active issue?

svallory commented 12 years ago

yes, and no. Yes, it is still an issue, and no, nobody is actually working on it, I whish I could work on it. But I'm too busy.

svallory commented 12 years ago

I'm gonna check if all the syntax's specified here are valid