带变量的Jekyll/Liquid表单模板

带变量的Jekyll/Liquid表单模板,jekyll,liquid,Jekyll,Liquid,有没有一种方法可以设计一个表单模板,供具有各种参数的内容页使用?大概是这样的: _布局/form.html 更好的解决方案是创建一些带有变量定义的YAML文件,这些变量定义被注入到模板中,用于说明表单页面的永久链接。此文件将用于生成结束表单页。您知道Jekyll中包含的文件吗 includes功能就像一个函数或一段可重用代码,而不是决定页面的布局,因此很难向其中添加内容。可以在页面或布局上使用 它可以很好地处理参数 从 \u include/image.html <figure>

有没有一种方法可以设计一个表单模板,供具有各种参数的内容页使用?大概是这样的:

_布局/form.html


更好的解决方案是创建一些带有变量定义的YAML文件,这些变量定义被注入到模板中,用于说明表单页面的永久链接。此文件将用于生成结束表单页。

您知道Jekyll中包含的文件吗

includes功能就像一个函数或一段可重用代码,而不是决定页面的布局,因此很难向其中添加内容。可以在页面或布局上使用

它可以很好地处理参数

\u include/image.html

<figure>
   <a href="{{ include.url }}">
   <img src="{{ include.file }}" style="max-width: {{ include.max-width }};"
      alt="{{ include.alt }}"/>
   </a>
   <figcaption>{{ include.caption }}</figcaption>
</figure>
或者传递变量名而不是值,如frontmatter或数据文件中定义的。注意不要用图像URL覆盖页面上的URL,否则会破坏内容

---
my_image:
  url: '...'
  alt: '...'
---
{% include image.html url=page.my_image.url alt=page.my_image.html ... %}

From _data/gallery.yaml

{% include image.html url=site.data.gallery.my_image.url 
... %}
或者传递带有属性的对象

---
my_image:
  url: '...'
  alt: '...'
---
{% include image.html image_attributes=page.my_image %}

你知道Jekyll中包含的文件吗

includes功能就像一个函数或一段可重用代码,而不是决定页面的布局,因此很难向其中添加内容。可以在页面或布局上使用

它可以很好地处理参数

\u include/image.html

<figure>
   <a href="{{ include.url }}">
   <img src="{{ include.file }}" style="max-width: {{ include.max-width }};"
      alt="{{ include.alt }}"/>
   </a>
   <figcaption>{{ include.caption }}</figcaption>
</figure>
或者传递变量名而不是值,如frontmatter或数据文件中定义的。注意不要用图像URL覆盖页面上的URL,否则会破坏内容

---
my_image:
  url: '...'
  alt: '...'
---
{% include image.html url=page.my_image.url alt=page.my_image.html ... %}

From _data/gallery.yaml

{% include image.html url=site.data.gallery.my_image.url 
... %}
或者传递带有属性的对象

---
my_image:
  url: '...'
  alt: '...'
---
{% include image.html image_attributes=page.my_image %}