[Rails] Re: Rails Syntax Change
> New: <%= yield(:title) %>
> Old: <%= @title %>
@title is set in a controller, and to separate views from what goes on
in a controller, you shouldn't set a title of an html page in a
controller. The method yield(:title) looks for the value of a title
variable in the view, which can be set like this:
<% provide(:title, "Home") %>
> New: "#{base_title} | Home"
> Old: @base_title + "| Home"
Those statements do the exact same thing in ruby. The first example
injects a second string into the first string. The second example joins
two strings together--producing a third string. So the second example is
a tiny bit more efficient.
--
Posted via http://www.ruby-forum.com/.
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home