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

How to Switch to Blade Template Engine?

I love volt, I seriously do. But I also use a awesome javascript framework called vue.js. But the problem is I can't use vue.js with Phalcon's volt template engine. If I could somehow comment out a line e.g: "@{{ name }}" like in blade then I'd stick with volt. But I've looked up about volt and as far as I have read you can't comment something out like above. So I wish to switch to blade, because of this issue. But how would I do that?



59.9k

Hi,

don't know if you mean this:

https://docs.phalcon.io/en/3.0.0/reference/volt.html#comments


145.0k
Accepted
answer

Which issue? Im using volt with angular and don't have any problem. Just add this function:

                    $compiler = $volt->getCompiler();
                    $compiler->addFunction('ngb', function ($resolvedArgs, $exprArgs) use ($compiler) {
                        $value = $compiler->expression($exprArgs[0]['expr']);

                        return '"{{".'.$value.'."}}"';
                    });

and {{ ngb("name") }} in volt will cause to display it in view as {{ name }} so your vue variable will just work.

Which issue? Im using volt with angular and don't have any problem. Just add this function:

                   $compiler = $volt->getCompiler();
                   $compiler->addFunction('ngb', function ($resolvedArgs, $exprArgs) use ($compiler) {
                       $value = $compiler->expression($exprArgs[0]['expr']);

                       return '"{{".'.$value.'."}}"';
                   });

and {{ ngb("name") }} in volt will cause to display it in view as {{ name }} so your vue variable will just work.

Neat, I didn't know you could infact add a function to the volt compiler. I'll take this is my answer.



2.7k

for example:

new Vue({ delimiters: ['${', '}'], });

<span v-show="errors.has('email')" >${ errors.first('email') }</span>

or :

<span v-show="errors.has('email')" v-text="errors.first('email')"></span>