我们如何在变量中创建自定义液体变量(即自定义液体对象)?
How can we create custom liquid variables within variables (i.e., custom liquid objects)?
让我们考虑以下代码:
---
layout: post
title: "Welcome to Jekyll!"
test:
name: google.com
---
{{ post.test.name }}
{% assign addr="https://www.google.com" %}
# Heading
This is a link to [the Google homepage!][ghome]
This is another link that [may or maynot work][glink]
[ghome]: https://google.com
[glink]: {{ addr }}
正确输出:
然而,当我尝试做同样的事情但将 addr
更改为 test.addr
(因此将其转换为 test
的数据成员,link 中断:
- 如何使上述工作正常进行?!
- 如何向页面前面描述的变量
page.test
添加一个新的 属性?
在Page
内,数据单向流动。
Front Matter
=>
Content
您可以执行以下操作:
{% assign addr = page.test.name %}
[link][glink]
[glink]: {{ addr }}
但是您不能执行以下操作:
{% assign page.test.addr = "https://www.google.com" %}
[link][glink]
[glink]: {{ page.test.addr }}
让我们考虑以下代码:
---
layout: post
title: "Welcome to Jekyll!"
test:
name: google.com
---
{{ post.test.name }}
{% assign addr="https://www.google.com" %}
# Heading
This is a link to [the Google homepage!][ghome]
This is another link that [may or maynot work][glink]
[ghome]: https://google.com
[glink]: {{ addr }}
正确输出:
然而,当我尝试做同样的事情但将 addr
更改为 test.addr
(因此将其转换为 test
的数据成员,link 中断:
- 如何使上述工作正常进行?!
- 如何向页面前面描述的变量
page.test
添加一个新的 属性?
在Page
内,数据单向流动。
Front Matter
=>
Content
您可以执行以下操作:
{% assign addr = page.test.name %}
[link][glink]
[glink]: {{ addr }}
但是您不能执行以下操作:
{% assign page.test.addr = "https://www.google.com" %}
[link][glink]
[glink]: {{ page.test.addr }}