符号比较在 liquid 语法中不起作用

Comparison of the sign does not work in the liquid syntax

我遇到了一个简单而无聊的错误。该任务添加一定数量的charset值符合一个循环。但是,段语法上的 liquid 拒绝这样做。

{% assign text = 'Some example text here' %}  // Variable here
{% unless text.size < 100 %}                  // Start loop
    {% assign text = text | append: '#' %}    // Concate and iterate at the same time
{% endunless %}                               // End loop
                      
{{text}}                                      // Output value to screen

作为结果,我希望看到这样的结果:这里有一些示例文本############################ #################################################

请帮忙!

你不能用 Unless 循环,除非只触发一次。

{% assign text = 'Some example text here' %}

{% for i in (1..100) -%}
    {% if i == text.size -%}
        {% break %}
    {% else -%}
        {% assign text = text | append: '#' %}
    {% endif -%}
{% endfor -%}
{{text}}