Ruby javascript block not rendering

24 views
Skip to first unread message

François Montel

unread,
Nov 23, 2009, 12:36:12 PM11/23/09
to Haml
Wondering why the following doesn't not work (no error, but doesn't
generate the javascript):

<pre>
= link_to_function('CONTRIBUTE', nil, :style =>
"background:none;") do |page|
page.visual_effect(:blind_up, 'search', { :duration => 0.5 })
page.visual_effect(:toggle_blind, 'submit', { :duration =>
0.5 })
</pre>

I extracted it to a helper and it works okay, but according to the
haml docs, I should be able to put a block like this in my haml view.

Nathan Weizenbaum

unread,
Nov 23, 2009, 1:52:01 PM11/23/09
to ha...@googlegroups.com
The problem is that the code within the block isn't registered by Haml as Ruby code. It just looks like plain text. If you add a hyphen in front of the lines you want to be interpreted as Ruby, the code should work.

2009/11/23 François Montel <zero...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=.



François Montel

unread,
Nov 23, 2009, 5:31:25 PM11/23/09
to Haml
Ah, okay. Got it. Do I need to preface with = those lines within a
block that output HTML? Or does the = on the first line of the block
take care of that and I can just use - for the lines within the
block?

On Nov 23, 12:52 pm, Nathan Weizenbaum <nex...@gmail.com> wrote:
> The problem is that the code within the block isn't registered by Haml as
> Ruby code. It just looks like plain text. If you add a hyphen in front of
> the lines you want to be interpreted as Ruby, the code should work.
>
> 2009/11/23 François Montel <zeroh...@gmail.com>
>
>
>
> > Wondering why the following doesn't not work (no error, but doesn't
> > generate the javascript):
>
> > <pre>
> >    = link_to_function('CONTRIBUTE', nil, :style =>
> > "background:none;") do |page|
> >      page.visual_effect(:blind_up, 'search', { :duration => 0.5 })
> >      page.visual_effect(:toggle_blind, 'submit', { :duration =>
> > 0.5 })
> > </pre>
>
> > I extracted it to a helper and it works okay, but according to the
> > haml docs, I should be able to put a block like this in my haml view.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Haml" group.
> > To post to this group, send email to ha...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > haml+uns...@googlegroups.com <haml%2Bunsu...@googlegroups.com>.

Nathan Weizenbaum

unread,
Nov 23, 2009, 5:53:32 PM11/23/09
to ha...@googlegroups.com
The = on the first line suffices. Think about how you would do it in ERB: you'd wrap the entire block in <%= %>. It's basically the same idea in Haml.

2009/11/23 François Montel <zero...@gmail.com>
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages