What does that == do in there?
On Apr 27, 1:28 pm, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
> There's not a great, general way to do this in Haml 1.8. For the first
> example, you could do
>
> - content_for :onload_scripts do
> == $(#{highlighted_item.to_json}).effect('highlight');
>
> Calling out to ERB is probably the best option for the second script.
>
> However, in the master branch you can use filters with variable
> interpolation, like so:
>
> - content_for :onload_scripts do
> :plain
> $('#search_items').autocomplete(
> #{url_for(:controller => '/items', :action => 'search').to_json},
> { selectFirst: false, minChars: 2 });
>
> Note that I'm calling to_json on the strings before putting them into
> the document; that guarantees that they'll result in valid Javascript.
>
> - Nathan
>
> Jesús wrote:
> > Hi, i've just met Haml (and i love it!), but i'm having problems
> > translating some erb views.
>
> > i usually have (erb) code like this:
>
> > <% content_for :onload_scripts do %>
> > $('#<%= highlighted_item %>').effect('highlight');
> > <% end %>
>
> > or
>
> > <% content_for :onload_scripts do %>
> > $('#search_items').autocomplete(
> > '<%= url_for :controller => '/items',
> > :action => 'search' %>', {
> > selectFirst: false,
> > minChars: 2
> > });
> > <% end %>
>
> > ie, to generate javascript with erb.
>
> > How can i write code like this in haml that doesn't suck? i think that
> > the only way to do this is with something respectively like:
>
> > - content_for :onload_scripts do
> > $('
> > = highlighted_item
> > ').effectt('highlight');
>
> > - content_for :onload_scripts do
> > $('#search_items').autocomplete('
> > = url_for :controller => '/items', :action => 'search'
> > ', {selectFirst: false, minChars: 2});
>
> > that's really ugly, don't you think? for now i'm using a
> > = render :partial => 'an_erb_file'
> > and putting all that stuff there, but that method sucks too :(
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---