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

Href with inside elements with Volt sintax!

Is possible do this whith volt sintax? Elements inside tag a

<a href="https://mysite.com">My Site!!
    <img src="logo.jpg" alt="Site" height="42" width="42">
    <p>My beautiful site!!!</p>
</a>

In Volt i know only this way, without inside elements...

{{ link_to('mysite.com', 'My Site') }}
{{ link_to('mysite.com', 'My Site!!<img src="logo.jpg" alt="Site" height="42" width="42"><p>My beautiful site!!!</p>') }}

// Or this way if it looks cleaner to you.

{% set innerHtml = '
    My Site!!
    <img src="logo.jpg" alt="Site" height="42" width="42">
    <p>My beautiful site!!!</p>
' %}
{{ link_to('mysite.com', innerHtml) }}

Display a error becouse my code have loops and ifs inside

<ul>
    {% set position = 0 %}
        {% for app in top_apps %}
            {% set position += 1 %}
            <li>
                <p>{{ position }}</p>
                {% if app.getUrlIconApp() != '' %}
                    {{ image('files/imgs/icon/'~app.getUrlIconApp() ) }}
                {% else %}
                    {{ image('files/imgs/default_icon.png') }}
                {% endif %}
                {{ link_to('show-app/'~app.getSlugApp(), app.getNameApp() ) }}
                {% for ai in app.getAppInfo() %}
                    {% if ai.getIdLangAvailableFkAppInfo() == id_lang %}
                        <div class="subheader">{{ ai.getAcessAppInfo() }} acessos</div>
                    {% endif %}
                {% endfor %}
            </li>
        {% endfor %}
</ul>

I need to put all code of <li> tag to inside a <a> tag.
Your code seems correct, but in my case don't works...

Well you can do it with some assignment to variables, but it will be painful to read. Actually I'm not really a big fan of link_to() function, i just use normal <a> tag. If I understood you right, wont this work for you?

<ul>
    {% set position = 0 %}
    {% for app in top_apps %}
        {% set position += 1 %}
        <li>
            <a href="{{ url('show-app/'~app.getSlugApp()) }}">
                {{ app.getNameApp() }}
                <p>{{ position }}</p>
                {% if app.getUrlIconApp() != '' %}
                    {{ image('files/imgs/icon/'~app.getUrlIconApp() ) }}
                {% else %}
                    {{ image('files/imgs/default_icon.png') }}
                {% endif %}

                {% for ai in app.getAppInfo() %}
                    {% if ai.getIdLangAvailableFkAppInfo() == id_lang %}
                        <div class="subheader">{{ ai.getAcessAppInfo() }} acessos</div>
                    {% endif %}
                {% endfor %}
            </a>
        </li>
    {% endfor %}
</ul>