2016-05-31 2 views
0

내 사이트에 구성 요소 집합이 있습니다.이 파일은 .yml 파일의 변수에 지정된 내용으로 채워집니다.(중첩 된) 지킬 변수를 덮어 쓰는 방법?

site.components/button.html

--- 
title: Button 
--- 
{% assign yml = 'sample' %} 
<a href="#">{{ site.data.[yml].button }}</a> 

데이터/sample.yml

#variables 
button: Click Me 

내가 이 /button.html 변수가 잘 작동하는 URL을 열 :

#Page Output 
<html> 
    <a href="#">Click Me</a> 
</html> 

Q : 구성 요소가 페이지에서 사용될 때 변수를 덮어 쓸 수있는 방법이 있습니까? 예 : 모든 성분이없는

--- 
title: A Sample Page 
--- 
{% assign yml = 'content'%} 
{{ site.components | where:"title" : "Button" }} 

데이터/content.yml

#variables 
button: Join Now 

/sample-page.html

#Page Output 
<html> 
    <a href="#">Join Now</a> 
</html> 

주 포함한다.

답변

2

답변은 아니오입니다.

{{ site.components | where:"title" : "Button" }}을 수행하면 제목과 일치하는 지킬 문서의 배열이 생성됩니다. 그 문서들은 이미 액체 파싱되어 있습니다. 지킬에게 그들을 다시 파싱하도록 지시 할 수는 없습니다.

유일한 방법은 includes를 사용하여 변수를 전달하는 것입니다.

_includes/button.html

<a href="#">{{ site.data.[include.text].button }}</a> 

_components/button.html

--- 
title: Button 
--- 
{% include button.html text='sample' %} 

샘플 page.html

--- 
title: A Sample Page 
--- 
{% include button.html text='content' %} 
관련 문제