/**
* @return array<TwigFunction>
*/
public function getFunctions(): array
{
return [
new TwigFunction('embedData', [$this, 'embedData'], ['is_safe' => ['html']]),
//new TwigFunction('exportStyles', [$this, 'exportStyles'], ['is_safe' => ['html']]),
];
}
/**
* @param mixed $data
*/
public function embedData($data, string $name): string
{
$ret = '<script type="application/json" id="' . $name . '">';
$ret .= json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$ret .= '</script>';
return $ret;
}
{% block body %}
{{ embedData(vue, 'app-data') }}
<div id="app" class="hide-on-load bg-white">
<checkout-frame language="de"></checkout-frame>
</div>
{% endblock %}
and explain how to use this:
{% block body %} {{ embedData(vue, 'app-data') }} <div id="app" class="hide-on-load bg-white"> <checkout-frame language="de"></checkout-frame> </div> {% endblock %}