Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll: Using values from _config.yml in SCSS partial

In my Jekyll project, I have the following in my _config.yml file:

colors:
  - name: red
    hex: '#FF0000'
  - name: yellow
    hex: '#FFFF00'
  - name: blue
    hex: '#0000FF'

In assets/css/colors.scss, I want to create classes for the colors as follows:

{% for color in site.colors %}
.{{ color.name }} {
  color: {{ color.hex }};
}
{% endfor %}

I want to @import the colors.scss file into main.scss, but I when I do so, I get the following error:

Error in _assets/css/background-test.scss:6 Invalid CSS after "}": expected selector or at-rule, was "{% for color in..." 
  Liquid Exception: Invalid CSS after "}": expected selector or at-rule, was "{% for color in..." in _includes/head.html, included in _layouts/default.html
jekyll 3.0.1 | Error:  Invalid CSS after "}": expected selector or at-rule, was "{% for color in..."

Is there a way to get Liquid to process the values from the _config.yml file in the SCSS partial?

like image 841
charliesneath Avatar asked Dec 15 '15 15:12

charliesneath


1 Answers

Only your main.scss will be parsed by Jekyll.

Once parsed with Liquid it is passed to sass/scss processor. So, any @imported file will not be parsed by Liquid.

like image 135
David Jacquel Avatar answered Oct 23 '22 14:10

David Jacquel