开发者

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

开发者 https://www.devze.com 2023-02-03 01:47 出处:网络
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 l

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

精彩评论

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