Ish*_*han 5 templating-engine liquid static-site jekyll
如何在 Jekyll 中多次重复字符串?
例如:在 Python 中,您可以"hello" * 5获取'hellohellohellohellohello'. 在 Jekyll 中,有比这更简单的方法来做同样的事情吗?
{% for i in (1..5) %}
Hello
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
例子
假设您想要显示星级,并且您正在使用它<i class="fa fa-star"></i>来显示每颗星。因此,要显示 5 星评级,您就可以这样做。
{% for i in (1..5) %}
<i class="fa fa-star"></i>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
单个页面上可能会显示许多评级,因此您将使用该 for 循环的多个实例。
| 归档时间: |
|
| 查看次数: |
686 次 |
| 最近记录: |