Reputation: 12605
I have the following code in a rails slim layout:
- if content_for(:body_tag)
yield :body_tag
- else
body
The :body_tag template will typically involve something like body ng-controller='myAngularAppController'
, for example
The problem is that any subsequent commands I make won't be nested inside the body tag. If I write
- if content_for(:body_tag)
yield :body_tag
- else
body
.container
...
The body
tag will close before the container starts. If I write
- if content_for(:body_tag)
yield :body_tag
- else
body
.container
...
The container wont render at all when a :body-tag
is specified.
I'm assuming this is a common problem. Any thoughts?
Upvotes: 1
Views: 994
Reputation: 4114
If the only thing that's going to be dynamic on the body
is the ng-controller
attribute, I would recommend accomplishing it like this:
body ng-controller=content_for(:controller)
Instead of specifying the entire tag with the :body_tag
identifier, just specify the body
tag statically (because that is static) and the dynamic controller you want to use with a :conroller
(or whatever you want to call it) identifier.
Upvotes: 1