html Jekyll Casts - Liquid:逻辑声明

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Jekyll Casts - Liquid:逻辑声明相关的知识,希望对你有一定的参考价值。

<!--
Next let’s get into some liquid logic statements to control whether the h1 is output on the page. We’ll add a new variable to the front matter called show_heading and initalize it to true. Then we’ll surround the h1 in an if statement to check if show_heading is true. 
-->

---
heading: I like cupcakes
show_heading: true
---

{% if page.show_heading %}
  <h1>{{ page.heading | upcase | truncate: 8 }}</h1>
{% endif %}

<!--
We can also add an elsif to the if statement to check other conditions. So if page.show_heading is false we’ll check if page.heading contains the word “cupcake”, if it does then we’ll output “I want cupcakes”, if it doesn’t we’ll have output I don’t want cupcakes. 
-->

---
heading: I like cupcakes
show_heading: false
---

{% if page.show_heading %}
  <h1>{{ page.heading | upcase | truncate: 8 }}</h1>
{% elsif page.heading contains "cupcake" %}
  <h1>I want cupcakes</h1>
{% else %}
  <h1>I don't want cupcakes</h1>
{% endif %}

以上是关于html Jekyll Casts - Liquid:逻辑声明的主要内容,如果未能解决你的问题,请参考以下文章

html Jekyll Casts - 循环液体

html Jekyll Casts - 液体:循环

html Jekyll Casts - Liquid:逻辑声明

html Jekyll Casts - JSON输出

html Jekyll Casts - 日期格式

html Jekyll Casts - 数据文件