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

Is there some way to use {% block... %} in link_to

Is there some way to use {% block... %} in link_to(). I am trying to use template inheritence. The below code adds literal {% block indexlink %}{% endblock %} into the link

<li class="previous">{{ link_to("{% block indexlink %}{% endblock %}", "Go Back") }}</li>

If I remove the double quotes then the compiler gives an error - unexpected token {%. If I remove {% blockand %} totally then it says Undefined variable: indexlink. Is there some way I can specify the link using a {% block... variable %}option.

Thanks



77.7k
Accepted
answer
edited Oct '17

No, but you can do this:

{% block indexLink %}
{% set indexLink = '/mylink' %}
{% endblock %}

<li class="previous">{{ link_to(indexLink, "Go Back") }}</li>

Or you could propagate a variable from the controller.