杰基尔继承
Jekyll inheritance
我有以下布局,使用 jekyll 3.7.3;
declare A = apple
include file.html > declare A = orange
print A => orange
我很困惑 A=orange
是如何在 jekyll's doc, says that the variables assess thru layout
in the liquid tag. Does this apply to the include
as well? It makes no sense in where child layout overwritten the parent layout, as it is saying in the github conversation and this conversation.
中泄漏到 parent 布局的
所以我的问题是这种继承是如何工作的?
根据我对继承的理解,应该对 child 变量如何覆盖 parent 变量进行一些控制。从文档来看,我相信它是通过变量layout
。那么这应该是这样的;
declare A = apple
include file.html > declare layout.A = orange
print A => apple
其他情况是;
声明 A = 苹果
包括 file.html > 打印 A => 苹果
declare A = orange
打印 A => 橙色
如果 child include
继承了值而没有明确告诉它,那么在 include 中有一个参数有什么意义。
也将泄漏变量放入 include
child,这意味着 child include
不再像现在这样出于特殊情况的目的而被隔离saying here
包含和布局不同。
在生成站点时,Jekyll 会按特定顺序执行很多操作。
- 读取页面数据
- 渲染液体
- 有必要
includes
- 计算液体标签和过滤器
- 呈现 html 以防文档是 markdown
- 渲染布局
当它呈现液体时:
=== page.html
include other.html
print a
assign: a = apple
print a
include other.html
=== end page.html
变成一堆代码这样处理:
=== page.html
====== other.html
print a ------> nil
assign: a = orange
print a ------> orange
====== end other.html
print a ------> orange
assign: a = apple
print a ------> apple
====== other.html
print a ------> apple
assign: a = orange
print a ------> orange
====== end other.html
=== end page.html
Liquid 标签完全按照它们在代码中出现的顺序执行,变量(在页面主体中分配的局部变量,而不是前面的那个 freezed 并且不能被更改)是全局的,可以从页面或任何子包含中覆盖。
此后,如果需要,它会渲染HTML,而"spits"页面的{{ content }}
在布局中对页面的局部变量一无所知,只能看到定义在前端的页面变量.
我有以下布局,使用 jekyll 3.7.3;
declare A = apple
include file.html > declare A = orange
print A => orange
我很困惑 A=orange
是如何在 jekyll's doc, says that the variables assess thru layout
in the liquid tag. Does this apply to the include
as well? It makes no sense in where child layout overwritten the parent layout, as it is saying in the github conversation and this conversation.
所以我的问题是这种继承是如何工作的?
根据我对继承的理解,应该对 child 变量如何覆盖 parent 变量进行一些控制。从文档来看,我相信它是通过变量layout
。那么这应该是这样的;
declare A = apple
include file.html > declare layout.A = orange
print A => apple
其他情况是;
声明 A = 苹果
包括 file.html > 打印 A => 苹果
declare A = orange
打印 A => 橙色
如果 child include
继承了值而没有明确告诉它,那么在 include 中有一个参数有什么意义。
也将泄漏变量放入 include
child,这意味着 child include
不再像现在这样出于特殊情况的目的而被隔离saying here
包含和布局不同。
在生成站点时,Jekyll 会按特定顺序执行很多操作。
- 读取页面数据
- 渲染液体
- 有必要
includes
- 计算液体标签和过滤器
- 有必要
- 呈现 html 以防文档是 markdown
- 渲染布局
当它呈现液体时:
=== page.html
include other.html
print a
assign: a = apple
print a
include other.html
=== end page.html
变成一堆代码这样处理:
=== page.html
====== other.html
print a ------> nil
assign: a = orange
print a ------> orange
====== end other.html
print a ------> orange
assign: a = apple
print a ------> apple
====== other.html
print a ------> apple
assign: a = orange
print a ------> orange
====== end other.html
=== end page.html
Liquid 标签完全按照它们在代码中出现的顺序执行,变量(在页面主体中分配的局部变量,而不是前面的那个 freezed 并且不能被更改)是全局的,可以从页面或任何子包含中覆盖。
此后,如果需要,它会渲染HTML,而"spits"页面的{{ content }}
在布局中对页面的局部变量一无所知,只能看到定义在前端的页面变量.