how to use stylesheet_link() for a less file ?

doc says that stylesheet_link accept an array of arguments. Because I want a rendered tag like this:

<link rel="stylesheet/less" type="text/css" href="style.less">

I tried:

{{ stylesheet_link(array("href"=>"style.css","type"=>"text/css","rel"="stylesheet/less")) }}

but that drops me an error : "Syntax error, unexpected token ASSIGN"

edited Jul '14

It depend what you use as your template engine, Volt or PHP If volt, you include css like this

{{ stylesheet_link("css/style.css") }}

or

{{ stylesheet_link("http://cdn.example.com/style.css", false) }} - for remote css

for stylesheets/less

{{ tag_html("link", ["rel":"stylesheet/less", "type":"text/css", "href":"style.less"]) }}

You should read all documentation if you want to use phalcon effectively. info about Include js, css is on page 207 from PDF documentation



81.8k

It must be:

{{ stylesheet_link(["href": "style.css", "type": "text/css", "rel": "stylesheet/less"]) }}

ups :) i updated my post and now see you aswer :) but i used html5 element, is it work?



81.8k

@doit76 yes!, your examples are also fine :)



27.6k
edited Jul '14

yes, it's the first time I use Volt. I didn't know that arrays are used in volt in a kind of json way ... Thanks both of you, but unfortunately none of your solutions work:

{{ tag_html("link", ["rel":"stylesheet/less", "type":"text/css", "href":"style.less"]) }}

or

{{ stylesheet_link(["href": "style.less", "type": "text/css", "rel": "stylesheet/less"]) }}

they do output the needed code:

<link rel="stylesheet/less" type="text/css" href="style.less">

but phalcon complains : "Service 'view' wasn't found in the dependency injection container"

with an "harcoded" link tag to the less file, eveythings works as expected.



81.8k

Are you using Volt outside of Phalcon\Mvc\View?



27.6k

no, I am not.



81.8k

Phalcon\Tag does not depend on Phalcon\Mvc\View to throw an exception with message: Service 'view' wasn't found in the dependency injection container



27.6k

OK, I agree. But I can't understand why while calling my less file with Volt, it drops me that error. It looks like error raise during less.js (LESS - Leaner CSS v1.3.3) script execution.

Doesn't matter right now, I'm working with <link rel="stylesheet/less" type="text/css" href="style.less"> and it's OK