Closed BananaAcid closed 4 years ago
The only purpose of block
variable is to know from inside the mixin declaration if the block have been filled or not on call. So to do if block
as a boolean answer. If someone made a strict test if block === true
changing the content of $block
will break this app.
As it's a breaking change I won't change the $block
variable.
Now there is still __pug_children(get_defined_vars())
to actually trigger manually the block. But it displays it, it does not return it.
In your example, it looks feasible but $__pug_children
is a closure that take locals variable and actually output in the sdtout.
So you need to catch the output:
mixin item
- ob_start()
- __pug_children(get_defined_vars())
- content = ob_get_contents()
- ob_end_clean()
div=strip_tags(content)
+item
| <b>hello</b>
It sounds still a bit like a tweaked pattern. Can you explain why you would add tags in mixin blocks then remove them from inside the mixin declaration ?
Thanks for the reply. Works great!
I have 2 reasons.
By any chance, do you know how to get the block data in pugjs?
It will be difficult, in pugjs, block
variable is a function doing basically:
function(){ pug_html = pug_html + "<p>"; pug_html = pug_html + "foo</p>"; }
Hello,
I encountered an issue with the following code:
First I thought, $block would be a function or class that would hold the content - but var_dump($block) results in (bool)true
I expected to get:
But I actually get:
Thanks!