You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was hoping to be able to make a pull request to add this behavior to Calliope, but it seems like it will be quite difficult: it looks like the reason that Calliope doesn't remove null values is that it simply translates Haml to EEx without doing any variable evaluation, and EEx has no corresponding feature to Haml's hash attributes (other than name="<%= value %>", which doesn't really do the trick in this case).
I think this points to an inconvenient fact: if Calliope is going to achieve feature parity with Haml, it probably needs to render directly to Elixir (AST, perhaps), rather than simply acting as an EEx preprocessor (just as Ruby Haml doesn't render to ERb). But that's a longer-term solution. In the shorter term, what would be a good way of achieving null attribute removal in Calliope? Or should we just bite the bullet and get rid of the EEx intermediate layer?
The text was updated successfully, but these errors were encountered:
I'm starting to work on an EEx-free Haml implementation at https://github.com/marnen/hamlex. I'd be happy to merge that into Calliope if there's interest (and if I manage to implement anything :) ).
In the original Ruby Haml implementation, when hash attributes are nil, they're removed from the hash. That is,
becomes
(see https://codepen.io/marnen/pen/eMgNRN/).
null
andnull_var
are both omitted.Calliope doesn't do this: instead, the same Haml renders to
so that there is an extraneous attribute.
I was hoping to be able to make a pull request to add this behavior to Calliope, but it seems like it will be quite difficult: it looks like the reason that Calliope doesn't remove null values is that it simply translates Haml to EEx without doing any variable evaluation, and EEx has no corresponding feature to Haml's hash attributes (other than
name="<%= value %>"
, which doesn't really do the trick in this case).I think this points to an inconvenient fact: if Calliope is going to achieve feature parity with Haml, it probably needs to render directly to Elixir (AST, perhaps), rather than simply acting as an EEx preprocessor (just as Ruby Haml doesn't render to ERb). But that's a longer-term solution. In the shorter term, what would be a good way of achieving null attribute removal in Calliope? Or should we just bite the bullet and get rid of the EEx intermediate layer?
The text was updated successfully, but these errors were encountered: