I have a two versions of my application layout, which are differs only in a few lines. Consider following example:
!!!
%html
%head
# a lot of cod
There is two another option to do, what actually the OP asked:
in your layout:
- if flag ||= false
# variant 1
- else
# variant 2
in your application controller (this is the trick):
layout 'application' # or whatever
in any kind of controller:
render :locals => { :flag => true }
My guess would be, the layout processing is happening later cause of the "dynamic" (not really) layout
definition and that generates the necessary methods for all the keys inside of local_assigns
. So maybe the instance variable is a performanter solution. Any thoughts about that? Please leave a comment.
You could just use the local_assigns
variable like:
- if local_assigns[:flag] ||= false
# variant 1
- else
# variant 2
and then in any of your controller:
render :locals => { :flag => true }