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

[Solved] Macros do not work!

It was suppose to work:

{%- macro error_messages(message, field, type) %}
    <div>
        <span class="error-type">{{ type }}</span>
        <span class="error-field">{{ field }}</span>
        <span class="error-message">{{ message }}</span>
    </div>
{%- endmacro %}

But it's not. It gives me a syntaxe error, and it the exactly same code as in the docs.

My volt config:

$di->setShared('view', function() use ($config) {
    $view = new \Phalcon\Mvc\View();

    $view->setViewsDir(__DIR__ . '/Views/');
    $view->registerEngines(array(
        '.volt' => function($view, $di) use ($config) {
            $volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);

            $volt->setOptions(array(
                'compiledPath' => $config->app->cacheDir, // __DIR__ . '/Views/cache';
                'compileAlways' => false,
                'compiledSeparator' => '_'
            ));

            return $volt;
        }
    ));

    return $view;
});

I tested the same code as you and it works. I'll try to find out what is going on project, it may be something specific.

Any suggestion on what I should check?

Thats my code in my view: https://gist.github.com/phcostabh/6183923

And the error: "Syntax error, unexpected token IDENTIFIER in /home/desenvolvimento/philippe.costa/public_html/Letras/adm/v1/app/Views/destaques/form.volt on line 5"

I had the same problem and opened a pull request to fix this: https://github.com/phalcon/cphalcon/pull/1033

Problem Solved! Thank you fellows!