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

My custom macro in volt is not working

This is my volt code

{%- 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 %}

{# Call the macro #}
{{ error_messages('type': 'Invalid', 'message': 'The name is invalid', 'field': 'name') }}

and this is my compiled code

<?php
$this->_macros['error_messages'] = function($__p = null)
{
    if (isset($__p[0])) {
        $message = $__p[0];
    } else {
        if (isset($__p["message"])) {
            $message = $__p["message"];
        } else {
            throw new \Phalcon\Mvc\View\Exception("Macro 'error_messages' was called without parameter: message");
        }
    }
    if (isset($__p[1])) {
        $field = $__p[1];
    } else {
        if (isset($__p["field"])) {
            $field = $__p["field"];
        } else {
            throw new \Phalcon\Mvc\View\Exception("Macro 'error_messages' was called without parameter: field");
        }
    }
    if (isset($__p[2])) {
        $type = $__p[2];
    } else {
        if (isset($__p["type"])) {
            $type = $__p["type"];
        } else {
            throw new \Phalcon\Mvc\View\Exception("Macro 'error_messages' was called without parameter: type");
        }
    }
?>
   <div>
        <span class="error-type"><?php
    echo $type;
?></span>
        <span class="error-field"><?php
    echo $field;
?></span>
        <span class="error-message"><?php
    echo $message;
?></span>
    </div><?php
};
$this->_macros['error_messages'] = \Closure::bind($this->_macros['error_messages'], $this);
?>

<?php
echo $this->callMacro('error_messages', array(
    'type' => 'Invalid',
    'message' => 'The name is invalid',
    'field' => 'name'
));
?>

Unfortunately, this code does not work

And does not display any error

Odd, that's the sample code from the docs...

What is your Phalcon version?

Phalcon 2.0.9