I have various pages that need multiple content_for
at the top i.e:
- content_for :title, AppConfig.product['slogan']
- content_for :class, 'brand'
That are used in my layout:
== render 'layouts/top_wrapper'
main[class="view-#{yield(:class)}-wrapper"]
section[class="content-outer-wrapper"]
div[class="row"]
div[class="large-12"]
div[class="content-inner-wrapper"]
div[class="row"]
div[class="large-12 large-centered columns text-center section-title"]
h1
== yield(:title)
div[class="row"]
div[class="large-12 large-centered columns"]
== yield
== render 'layouts/bottom_wrapper'
I was wondering if there is a way to merge them together into a single content_for?
No way. content_for
stringifies your input so you cannot pass e.g. an array through that. You're still able to serialize your data though
- content_for :title_and_class, [AppConfig.product['slogan'], 'brand'].join(';')
- slogan, style = yield(:title_and_class).split(';')
but it is a little bit weird.