Closed rudiedirkx closed 1 year ago
It is supported, but probably not in the way you expected it to be. The child block completely overwrites the block with the same name in the parent. So in your example, the assign=content
part is never executed. If you set assign=content
on the child block, it does work though:
038_parent.pl
{block name=content}{/block}Captured content is: {$content}
038_child.tpl
{extends file='038_parent.tpl'}
{block name=content assign=content}Content with lots of html here{/block}
result
Captured content is: Content with lots of html here
But I can't have the assignment depend on the child template.... The parent template decides what to do with the block output. Is my case not possible? In a different way, not with assign
.
In Twig you can 'call' a block from the parent in 2 ways:
{% block content %}{% endblock %}
if you just want to print/stream it inline, like a Smarty block.{% set content = block('content')|trim %}
if you want to do something with it, like check if it's empty after trimming the output, or show it twice, etc.Does Smarty have 2.?
Blocks can be nested, or you can nest the block in a {capture}. SimonOp 6 feb. 2023 om 03:06 heeft Rudie Dirkx @.***> het volgende geschreven: But I can't have the assignment depend on the child template.... The parent template decides what to do with the block output. Is my case not possible? In a different way, not with assign. In Twig you can 'call' a block from the parent in 2 ways:
{% block content %}{% endblock %} if you just want to print/stream it inline, like a Smarty block. {% set content = block('content')|trim %} if you want to do something with it, like check if it's empty after trimming the output, or show it twice, etc.
Does Smarty have 2.?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you modified the open/close state.Message ID: @.***>
In the child template:
In the parent template:
But
$content
is empty.assign
seems to be a valid parameter, but it's not used?