The change for universal interpoliation has been implemented here:
http://gist.github.com/jcnetdev/haml/commit/55b0bb02572e8387fbf7b96d00278a13e30306a5

This change allows any static text line with #{} in it to be
interpreted the same as if ==. It's done in the precompiler so it
should be wicked fast.

It was actually really easy to hook into the precompiler. Since we're
already doing this functionality for filters, I was able to use the
same helpers and apply it to lines of static text.

It includes 6 unit tests that verifies the functionality it every
scenario. Also, it includes a test that verifies escaped #{} display
as normal.

This change allows any static text line with #{} in it to be
interpreted the same as if ==. It's done in the precompiler so it
should be wicked fast.

It also works with auto-html escaping. So if you include an &, if
there's an #{} in that line, it will work that same as if it were an
&==.

I think %#{tag_name}= wouldn't be expected behavior because its not in
a content block. Just like no one will expect %div{#{attr_name} =>
"blah"} to work. Haml seems to have an extremely clear separation
between tag definition and content.

Would love to get your guys thought on this change. I think it's an
hugely positive one as it'll make haml documents amazingly simple for
interpolation.

Thanks

-Jacques


On Oct 12, 11:43 am, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
> I'm also a little worried about people taking it too far... someone
> recently posted a message about %#{tag_name}= ..., and I think allowing
> #{} to be ubiquitous within text would do more to encourage that.
>
> Chris Eppstein wrote:
> > Yes, if you change your double quotes to single quotes.
>
> > But \#{h @user.name} is more straight forward and already supported in
> > == mode.
>
> > Btw, I'm still +1 on this despite the need to occasionally escape.
> > Unfortunately, the fact that escaping is necessary means that it is
> > not a backwards compatible change.
>
> > chris
>
> > On Sep 30, 5:13 pm, Lawrence Pit <[EMAIL PROTECTED]> wrote:
>
> >>   An example interpolation is #{h @user.name}
>
> >> could be escaped as:
>
> >>   An example interpolation is #{ "#{h @user.name}" }
>
> >> Lawrence
>
> >>> It should be noted that doing so would create a need for escaping the
> >>> #{ sequence if it occurs naturally in text.
>
> >>> Chris
>
> >>> On Sep 30, 4:45 pm, Lawrence Pit <[EMAIL PROTECTED]> wrote:
>
> >>>> That's how I do it as well... I rarely use the == syntax. Only in cases
> >>>> like these:
>
> >>>>   == Hello #{h @user.name},
>
> >>>> which is nicer compared to:
>
> >>>>   Hello
> >>>>   = succeed ',' do
> >>>>     = h @user.name
>
> >>>> But of course simply this is even nicer:
>
> >>>>   Hello #{h @user.name},
>
> >>>> As indeed is already possible when defined within a filter block.
>
> >>>> I vote +1 on the proposal.
>
> >>>> Lawrence
>
> >>>>> While I don't find anything conceptually wrong and would even +1 this
> >>>>> because there's times it would be convenient, I simply do this:
>
> >>>>>http://gist.github.com/13840
>
> >>>>> -chris
>
> >>>>> On Sep 30, 6:16 am,JacquesCrocker<[EMAIL PROTECTED]> wrote:
>
> >>>>>> In the process of bombarding the world with open source haml rails  
> >>>>>> apps (see here, here, here), I've definitely noticed a few small  
> >>>>>> things haml could do to increase the readability of haml view code.
>
> >>>>>> The most important one that I would like to suggest is some kind of  
> >>>>>> universal interpolation of #{} without the requirement of beginning  
> >>>>>> the line with ==. I've been using == so much lately that its starting  
> >>>>>> to look pretty ugly. Seems like it would help a lot if that it was the 
> >>>>>>  
> >>>>>> standard. So my question to haml users is: what would be the speed and 
> >>>>>>  
> >>>>>> functionality implications of allowing #{} to be used anywhere without 
> >>>>>>  
> >>>>>> the requirement of ==?
>
> >>>>>> Here's a quick code example:http://gist.github.com/13805
>
> >>>>>> I imagine automatically treating every static content line as if it  
> >>>>>> were a == would make haml an order of magnitude slower. The trick  
> >>>>>> would be to specifically recognize the existence of #{} in content  
> >>>>>> blocks (hopefully via a super fast content eval) and automatically  
> >>>>>> turn the evaluation of that line to ==.
>
> >>>>>> I spent a little time looking at the the haml codebase to verify my  
> >>>>>> findings but things haven't clicked for me yet. Would love any  
> >>>>>> feedback from someone who has a better handle on the parser on whether 
> >>>>>>  
> >>>>>> this is possible without a huge problem in performance. Aside from the 
> >>>>>>  
> >>>>>> implementation details, is there anyone who would object functionality-
> >>>>>> wise to being able to use #{} anywhere in normal content blocks? Since 
> >>>>>>  
> >>>>>> #{} is a rarely used html token I don't think it would conflict with  
> >>>>>> peoples existing view code. And since this type of automatic  
> >>>>>> interpolation is already done by default within Filters, it seems a  
> >>>>>> natural extension to use it in normal content blocks.
>
> >>>>>> Would love feedback on anything regarding the idea or implementation  
> >>>>>> challenges. Maybe I'm way off base here, but if it sounds like  
> >>>>>> something that had a remote chance to be added to haml core, I can do  
> >>>>>> some hacking on a fork and see how it goes.
>
> >>>>>> Thanks
>
> >>>>>> -Jacques
> >>>>>> railsjedi.com
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to