Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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('


10.2k
edited Dec '15

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

for {{ {{}} }} will produce <?php <?php ?> ?>



36.3k
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>


10.2k
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>


36.3k

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>


36.3k

HOW TO PUT THE COMMENT IN A BLACK AREA?



10.2k
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 #}