Longshot, but I'm wondering if there's any way to do something like this:
%p # ONLY SHOW THIS IF LOCAL VARIABLE show_paras IS TRUE
= name
In other words, it always shows the content inside, but it only wraps a container around it if (some-condition) is true.
You could use raw html, but then you'd have to have the if statement both at the beginning and end:
Assuming you're doing more than just
= name
, you could use a partial:You could also use HAML's
surround
(though this is a little messy):Finally, what I would probably do is not try to omit the
p
tag at all, and just use CSS classes to set up two differentp
styles to look the way I want:The cleanest way I can think of doing is like this:
But it's not exactly haml.
Generally markup is the for the content, so if show_paras is a more presentational tweak you should probably be using css to change the behaviour of the %p instead
https://github.com/haml/haml/commit/66a8ee080a9fb82907618227e88ce5c2c969e9d1
Another option is to wrap it in an alternative tag if the condition isn't met, using
haml_tag
: