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

Error when using URL in volt

Hey there; I want to draw a picture on a volt and that this has a URL so that the direction changes the image is preserved but have an internal error. This is the image

                {{ link_to('meppersona/new',"<img src='{{url("img/tolbar/User-blue32.png")}}'> Crear una nueva persona", ' class ': 'expanded warning button ') }}

The following error is this

            Syntax error, unexpected token IDENTIFIER(img) in /var/www/html/mep/app/config/../../app/views/meppersona/index.volt on line 16
#0 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->_compileSource('


31.3k
edited Dec '15

I think {{ }} can not be nest like this: {{ link_to( {{ url() }} ) }}! And {{ link_to( url() ) }} will be ok.

for {{ {{{% endraw %{% raw %}}}} }} will produce <?php <?php ?> ?>



81.2k
edited Dec '15

I write

{{ link_to('meppersona/new',"<img src='URL(' img/tolbar/User-blue32.png ' )'> Crear una nueva persona", ' class ': 'expanded warning button ') }}

But the result is on the web

    <a href="/mep/meppersona/new" class="expanded warning button "><img src="URL(" img="" tolbar="" user-blue32.png="" '="" )'=""> Crear una nueva persona</a>


31.3k
edited Dec '15

try

{{ link_to('meppersona/new','<img src='~url('img/tolbar/User-blue32.png')~'> Crear una nueva persona', ' class ': 'expanded warning button ') }}

I write

{{ link_to('meppersona/new',"<img src='URL(' img/tolbar/User-blue32.png ' )'> Crear una nueva persona", ' class ': 'expanded warning button ') }}

But the result is on the web

  <a href="/mep/meppersona/new" class="expanded warning button "><img src="URL(" img="" tolbar="" user-blue32.png="" '="" )'=""> Crear una nueva persona</a>


81.2k

HTML RESULT IS

<a href="/mep/meppersona/new" class="expanded warning button "><img src="/mep/" img="" tolbar="" user-blue32.png=""> Crear una nueva persona</a>


81.2k

HOW TO PUT THE COMMENT IN A BLACK AREA?



31.3k
Accepted
answer
edited Dec '15

This works well for me

{{ link_to('meppersona/new','<img src='~url('img/tolbar/User-blue32.png')~'> Crear una nueva persona', ' class ': 'expanded warning button ') }}

or you can try mixed up html and volt

<a href="{{ url('yoururl') }}"><img src="{{ url('yourimg') }}"></a>

COMMENT IN VOLT

{# comments #}