I'm using the https://api.drupal.org/InlineTemplate to render a string with a variable, and that variable is itself another theme function.
My reading of the documentation is that this is supported; based on the fact that the #context
variable can be a string or render array.
#context: (array) The variables to substitute into the Twig template. Each variable may be a string or a render array.
However, my implementation is not working:
$my_subtemplate = [
'#type' => 'inline_template',
'#template' => '{% trans %}my {{ foo }} here{% endtrans %}',
'#context' => ['foo' => 'bar'],
];
$my_string_with_embedded_themable = [
'#type' => 'inline_template',
'#template' => '{% trans %}Print this string and this subtemplate: {{ my_subtemplate }}.{% endtrans %}',
'#context' => [
'my_subtemplate' => $my_subtemplate,
],
];
The generated output is:
Print this string and this subtemplate: .
I've confirmed that my_subtemplate generates the correct output on its own:
my bar here
But when its placed into a variable of another inline template, it does not render.