We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Raw HTML in volt

How do I pass raw html into volt?

I need to print {{ hello }} into my html document, how is this done, without phalcon compile it to <?php echo $hello; ?>

Thanks!

Do you mean literally print?

{literal}
{{ hello }}
{/literal}

It would comple it: <?php echo "{{ hello }}"; ?>

Yes, i really need to see {{ hello }}

The reason is that I use handlebars, so I can't use the tag {{ }} - Unless I make volt ignore the tag..



10.4k
Accepted
answer
edited Aug '16

Doesn't {{ "{{ hello }}" }} do what you need?

You can add custom function for volt https://docs.phalcon.io/en/latest/reference/volt.html

$compiler->addFunction('print', function($resolvedArgs, $exprArgs)  use ($compiler) {
    return "print(". $compiler->expression($exprArgs[0]['expr']) .")";
});

And use it in volt:

I want to print {% print("hello") %}

Sorry for the late reply, I used Miguel Nunes answer

Thanks for all who spend their time helping me out :-)