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.

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?



19.6k

Hi,

don't know if you mean this:

https://docs.phalconphp.com/en/3.0.0/reference/volt.html#comments


107.2k
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:

```php $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.

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>