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

Volt - using a variable in stylesheet_link argument (SOLVED)

I'm passing an assets_base_url variable to my view.

The following works for loading a stylesheet.

<link rel="stylesheet" href="{{ assets_base_url }}css/app.css">

However, I was wondering if it was possible to use that variable within the stylesheet_link method to output the entire tag. I tried it this way, but it doesn't work.

{{ stylesheet_link( assets_base_url . 'css/app.css') }}



269
Accepted
answer
edited Mar '14

To concat strings use '~'.

{{ stylesheet_link( assets_base_url ~ 'css/app.css') }}

Also you could use static urls (https://docs.phalcon.io/en/latest/reference/url.html#static-vs-dynamic-uris)



3.1k

Static urls! That's perfect. I can't believe I missed that when reading the docs.

Thanks bro!