This project is archived and is in readonly mode.
link_to_unless and link_to_unless_current deprecation warnings
Reported by Rob Cameron | July 20th, 2010 @ 05:25 PM
I'm using HAML as my template engine. When using either
link_to_unless
or
link_to_unless_current
:
- link_to_unless(controller.controller_name == 'home', 'Dashboard', root_path) do
%span Dashboard
I get a deprecation warning about starting with a minus. Fair enough:
DEPRECATION WARNING: - style block helpers are deprecated. Please use =.
(called from _render_template_2471452342752540530_2154256720__1773247589947495410
at /Users/rob/Sites/my_app/app/views/layouts/application.html.haml:37)
So, I switch to using the equals version, however now I get the number 6 output after my span!
http://skitch.com/cannikin/dpeim/active-trainer-2-the-return
http://skitch.com/cannikin/dpeip/source-of-http-localhost-3000
Happens every time, no matter the length of the text in the block. If I switch filters to :erb and then write the code, and do NOT use equals, I don't get the deprecation warning and everything outputs okay:
:erb
<% link_to_unless(controller.controller_name == 'home', 'Dashboard',
root_path) do %>
<span>Dashboard</span>
<% end %>
If I use the = version I get an error!
/Users/rob/Sites/my_app/app/views/layouts/application.html.haml:
35: syntax error, unexpected ')'
...), 'Dashboard', root_path) do ).to_s); _erbout.concat "\n ...
... ^
/Users/rob/Sites/my_app/app/views/layouts/application.html.haml:
49: syntax error, unexpected keyword_end, expecting ')'
end;_hamlout.push_text(" #{_h...
^
/Users/rob/Sites/my_app/app/views/layouts/application.html.haml:
65: syntax error, unexpected keyword_ensure, expecting ')'
...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer....
... ^
/Users/rob/Sites/my_app/app/views/layouts/application.html.haml:
65: syntax error, unexpected keyword_end, expecting ')'
...buffer = @haml_buffer.upper;end;
... ^
/Users/rob/Sites/my_app/app/views/layouts/application.html.haml:
68: syntax error, unexpected keyword_end, expecting ')'
I posted this issue over at the HAML Google Group and Nathan (the author) says it's a Rails bug, not HAML: http://groups.google.com/group/haml/browse_thread/thread/b01da24f0d...
Thanks,
Rob
Comments and changes to this ticket
-
José Valim July 20th, 2010 @ 11:24 PM
- Assigned user set to José Valim
- Importance changed from to Low
Could you try to add a failing test case to Rails test suite?
-
Repository July 21st, 2010 @ 02:23 PM
- State changed from new to resolved
(from [e13e8dcf44fd27332ecd4e5c943d3d09efb58c96]) Use capture instead of yield in link_to_unless.
[#5162 state:resolved] http://github.com/rails/rails/commit/e13e8dcf44fd27332ecd4e5c943d3d...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 5162 link_to_unless and link_to_unless_current deprecation warnings [#5162 state:resolved] http://github.com/rails/rails/com...