cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

How mature is Volt?

Open awesselius opened this issue 13 years ago • 6 comments

I've tried 0.9.0, 0.9.1, master and 1.0.0 and this issue keeps staying in there. Maybe I do something wrong, but it's very simple actually.

I get this:

PhalconException: Syntax error, unexpected token %} in ../app/views/examples/index.volt on line 1

By typing this in index.volt:

{% cache %} test {% endcache %}

If I use this:

{% cache test %} test {% endcache %}

I get:

Notice: Undefined variable: test in .... index.volt on line 1

I also saw the filter 'capitalize' didn't work and some other problems with Volt. I can't get it to work from the examples in the tutorial about Volt.

So my question is: how mature is Volt? Thanks, and keep up the good stuff!

awesselius avatar Mar 01 '13 11:03 awesselius

Hi You forgot the quotes

{% cache "test" %}
test
{% endcache %}

iforp avatar Mar 01 '13 11:03 iforp

Ah, thanks! I didn't forgot them, they weren't in the example I found somewhere. But it still doesn't explain why the capitalize filter doesn't work. I'll try how far I can go with the tutorials.

awesselius avatar Mar 01 '13 12:03 awesselius

I can confirm it, capitalize isn't work

{{ "hello"|capitalize }}
// Phalcon\Mvc\View\Exception
// Unknown filter "capitalize"

iforp avatar Mar 01 '13 13:03 iforp

I tried to register an alternative filter for the compiler, like ucwords or ucfirst, but that doesn't work either.

awesselius avatar Mar 01 '13 15:03 awesselius

Filter registration works fine

$volt = new \Phalcon\Mvc\View\Engine\Volt($this->view, $this->di);
$compiler = $volt->getCompiler();
$compiler->addFilter('ucwords', 'ucwords');
var_dump($compiler->compileString('{{ "hello"|ucwords }}'));
// string '<?php echo ucwords('hello'); ?>' (length=31)

iforp avatar Mar 01 '13 16:03 iforp

I have issued a fix for capitalize in the 1.0.0. branch

niden avatar Mar 02 '13 20:03 niden