Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sass Jekyll:在SCSS中使用来自_config.yml的值_Sass_Jekyll_Liquid - Fatal编程技术网

Sass Jekyll:在SCSS中使用来自_config.yml的值

Sass Jekyll:在SCSS中使用来自_config.yml的值,sass,jekyll,liquid,Sass,Jekyll,Liquid,在我的Jekyll项目中,我的\u config.yml文件中有以下内容: colors: - name: red hex: '#FF0000' - name: yellow hex: '#FFFF00' - name: blue hex: '#0000FF' 在assets/css/colors.scss中,我想为颜色创建如下类: {% for color in site.colors %} .{{ color.name }} { color: {{

在我的Jekyll项目中,我的
\u config.yml
文件中有以下内容:

colors:
  - name: red
    hex: '#FF0000'
  - name: yellow
    hex: '#FFFF00'
  - name: blue
    hex: '#0000FF'
assets/css/colors.scss
中,我想为颜色创建如下类:

{% for color in site.colors %}
.{{ color.name }} {
  color: {{ color.hex }};
}
{% endfor %}
当我这样做时,我会得到以下错误:

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..."

有没有办法让Liquid处理SCSS中
\u config.yml
文件中的值?

如果你想让Jekyll处理你的SCSS文件,你必须添加一个前置项

这项工作:

---
# empty front matter
---
@charset "utf-8";

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

谢谢,这就行了。液体标签在SCSS部分中似乎不起作用,但这是一个基本的限制。所以,也许你可以批准这个答案。