Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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..



4.2k
Accepted
answer
edited Aug '16

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

You can add custom function for volt https://docs.phalconphp.com/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 :-)