开发者

Providing default content for section in layout(rails 3 .erb)

Is it possi开发者_如何学Pythonble to provide default content for section in layout if it is not overridden in view?


if you are using, say a title tag in your head section of your application.html.erb layout file, you could do something as simple as <%= @title || "Some Default App Content" %>

Using this same approach, you can use it for content_for and other helper methods.


Now, Rails have content_for? method for it: http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜