matthodan / jekyll-asset-pipeline

Powerful asset pipeline for Jekyll that collects, converts and compresses JavaScript and CSS assets
http://www.matthodan.com/2012/11/22/jekyll-asset-pipeline.html
MIT License
364 stars 31 forks source link

Insert a css or js file in a manifest stored in a page variable #18

Open fcalderan opened 11 years ago

fcalderan commented 11 years ago

I'd like to define a specific css for a single included page in this way


---
layout: default.html
css: page.css.scss

---
My customized page

and in my layout page I'd like to add this custom css like so

<!-- layout style -->
{% css_asset_tag global %} 
- /_assets/css/test.css.scss   <-- this works correctly
 {% endcss_asset_tag %}

<!-- page style -->
/_assets/css/{{ page.css }} <-- this correctly print /_assets/css/page.css.scss

{% if page.css %}
    {% css_asset_tag local %}
- /_assets/css/{{ page.css }}  <-- this fails
    {% endcss_asset_tag %}
{% endif %}

but when I run jekyll I've got an error:

Configuration from /Users/fcalderan/www/root/jekyll/_config.yml
Building site: ./src -> ./static
Asset Pipeline: Processing 'css_asset_tag' manifest 'global'
Configuration from /Users/fcalderan/www/root/jekyll/_config.yml
Configuration from /Users/fcalderan/www/root/jekyll/_config.yml
Asset Pipeline: Saved 'test.css' to '/Users/fcalderan/www/root/jekyll/static/css'
Asset Pipeline: Processing 'css_asset_tag' manifest 'local'
Asset Pipeline: Failed to load assets from provided manifest.
Liquid Exception: Is a directory - /Users/fcalderan/www/root/jekyll/src/_assets/css/ in default
...

I'm not sure but I suppose the interpolation of the string with the css filename is failing inside {% css_asset_tag %} block. There's a way to include a custom style or is it not possible? Or there's a better way to achieve the same result?

Thank you.

matthodan commented 11 years ago

I'm afraid you are right. It looks like the asset manifest is being processed before liquid tags within the manifest. I'm not sure how you can get around this, but let me know if you find a solution. I would be happy to update the lib with your solution or revise the docs to explain a workaround.