HI,
i''m trying to write a helper that replaces link_to_remote that  
accepts a block but it gets a compile error in the template:
I don''t know what I''m doing wrong... TIA
# application_helper.rb
   def link_block_to_remote( options = {}, html_options = {}, &block)
     concat(link_to_remote(capture(&block), options, html_options),  
block.binding)
   end
# in template
           <% link_block_to_remote
               {:url => { :action => :start_login } },
               { :href => url_for( { :action => :start_login }), #  
when degraded
               :class => "home-box home-box2",
               :id => "home-login-container"}  do %>
             <h1>LOGIN</h1>
             <p>Already have an account?</p>
             <p>LOG IN NOW</p>
           <% end %>
# the error I get is a compile error
compile error
syntax error, unexpected tASSOC, expecting ''}''
_erbout.concat "          ";  link_block_to_remote { :url =>  
{ :action => :start_login } },
                                                             ^
syntax error, unexpected '','', expecting kEND
_erbout.concat "          ";  link_block_to_remote { :url =>  
{ :action => :start_login } },
                                                                         
                     ^
syntax error, unexpected kDO, expecting kEND
                               :id => "home-login-container"}  do ;
_erbout.concat "\n"
# if i remove the html_options from the call, and remove the braces,  
it is ok
<% link_block_to_remote :url => { :action => :start_login }  do 
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
does it help if you use parenthesises around for
link_block_to_remote() ? (which by the way is good style)
           <% link_block_to_remote
(
               {:url => { :action => :start_login } },
               { :href => url_for( { :action => :start_login }), #when
degraded
               :class => "home-box home-box2",
               :id => "home-login-container"}
)  do %>
             <h1>LOGIN</h1>
             <p>Already have an account?</p>
             <p>LOG IN NOW</p>
           <% end %>
marcel
On 28 Mai, 08:56, Jonathan Linowes
<lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> HI,
> i''m trying to write a helper that replaces link_to_remote that
> accepts a block but it gets a compile error in the template:
> I don''t know what I''m doing wrong... TIA
>
> # application_helper.rb
>    def link_block_to_remote( options = {}, html_options = {}, &block)
>      concat(link_to_remote(capture(&block), options, html_options),
> block.binding)
>    end
>
> # in template
>            <% link_block_to_remote
>                {:url => { :action => :start_login } },
>                { :href => url_for( { :action => :start_login }), #
> when degraded
>                :class => "home-box home-box2",
>                :id => "home-login-container"}  do %>
>              <h1>LOGIN</h1>
>              <p>Already have an account?</p>
>              <p>LOG IN NOW</p>
>            <% end %>
>
> # the error I get is a compile error
>
> compile error
> syntax error, unexpected tASSOC, expecting ''}''
> _erbout.concat "          ";  link_block_to_remote { :url =>
> { :action => :start_login } },
>                                                              ^
> syntax error, unexpected '','', expecting kEND
> _erbout.concat "          ";  link_block_to_remote { :url =>
> { :action => :start_login } },
>
>                      ^
> syntax error, unexpected kDO, expecting kEND
>                                :id => "home-login-container"} 
do ;
> _erbout.concat "\n"
>
> # if i remove the html_options from the call, and remove the braces,
> it is ok
>
> <% link_block_to_remote :url => { :action => :start_login }  do
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
yep that took care of it, thanks (my first helper using &block :)) On May 28, 5:36 am, lanzm <marcel.l...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> does it help if you use parenthesises around for > link_block_to_remote() ? (which by the way is good style) > > <% link_block_to_remote > ( > {:url => { :action => :start_login } }, > { :href => url_for( { :action => :start_login }), #when > degraded > :class => "home-box home-box2", > :id => "home-login-container"} > ) do %> > <h1>LOGIN</h1> > <p>Already have an account?</p> > <p>LOG IN NOW</p> > <% end %> > > marcel > > On 28 Mai, 08:56, Jonathan Linowes <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > HI, > > i''m trying to write a helper that replaces link_to_remote that > > accepts a block but it gets a compile error in the template: > > I don''t know what I''m doing wrong... TIA > > > # application_helper.rb > > def link_block_to_remote( options = {}, html_options = {}, &block) > > concat(link_to_remote(capture(&block), options, html_options), > > block.binding) > > end > > > # in template > > <% link_block_to_remote > > {:url => { :action => :start_login } }, > > { :href => url_for( { :action => :start_login }), # > > when degraded > > :class => "home-box home-box2", > > :id => "home-login-container"} do %> > > <h1>LOGIN</h1> > > <p>Already have an account?</p> > > <p>LOG IN NOW</p> > > <% end %> > > > # the error I get is a compile error > > > compile error > > syntax error, unexpected tASSOC, expecting ''}'' > > _erbout.concat " "; link_block_to_remote { :url => > > { :action => :start_login } }, > > ^ > > syntax error, unexpected '','', expecting kEND > > _erbout.concat " "; link_block_to_remote { :url => > > { :action => :start_login } }, > > > ^ > > syntax error, unexpected kDO, expecting kEND > > :id => "home-login-container"} do ; > > _erbout.concat "\n" > > > # if i remove the html_options from the call, and remove the braces, > > it is ok > > > <% link_block_to_remote :url => { :action => :start_login } do--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---