【发布时间】:2016-05-31 12:14:58
【问题描述】:
我的站点中有一组组件,它们填充了由 .yml 文件中的变量指定的内容。
site.components/button.html
---
title: Button
---
{% assign yml = 'sample' %}
<a href="#">{{ site.data.[yml].button }}</a>
data/sample.yml
#variables
button: Click Me
当我打开网址 /button.html 时,该变量运行良好:
#Page Output
<html>
<a href="#">Click Me</a>
</html>
问:在页面中使用组件时,有什么方法可以覆盖变量吗?例如:
---
title: A Sample Page
---
{% assign yml = 'content'%}
{{ site.components | where:"title" : "Button" }}
data/content.yml
#variables
button: Join Now
/sample-page.html
#Page Output
<html>
<a href="#">Join Now</a>
</html>
注意组件不包括在内。
【问题讨论】: