Closed Nowaker closed 9 years ago
You must use =
instead of -
.
Check "Slim and Haml Content Blocks" section in Upgrading Padrino from 0.11.X to 0.12.0 Guide
Middleman use Padrino-helper and Middleman(> v3.3.0-3.3.2)'s behavier is changed when using slim and haml. (changelog)
Well, it works better but still not quite right. Since =
prints the returns value, I have a Proc in the output.
[#<Proc:0x007fd8c8daf7e8@/home/nowaker/projekty/ruby/virtkick-prototype/source/appliances.html.slim:38>]
After changing -
to @
in the minimal test case I provided the output is:
Content for A:Content A
Content for main:[#]Content Main[#]
Content for B:Content B
We see [#]
because <Proc ...>
part is considered as tag and thus not rendered by the browser.
Sorry, I don't know about Proc problem. This problem is not a bug by middleman-slim.
Please talk in Middleman Forum.
I found a workaround for this. You can write your content_for section this way:
- content_for :title, "My Title Is Here."
@milesegan Yes, but it's quite a poor workaround, applicable to short texts only.
@Nowaker Agreed. It would be nice to have a proper fix for this. But it was enough for me to move on and finish my project at least.
Looks like this should be closed. The problem has been fixed in middleman.
Yes, all fixed. Thanks @pedromaltez.
Consider this code:
And the layout:
The output is:
But should be:
What's interesting - it works OK when templates are in slim, and the layout is in ERB. The problem is somewhere in the layout rendering.
Somebody has already been affected by this. https://stackoverflow.com/questions/13954529/how-to-use-content-for-yield-content-in-middleman-using-slim
A minimal test case: https://github.com/Nowaker/middleman-slim-bugreport