gpt4 book ai didi

whitespace - Handlebars ,空白控制

转载 作者:行者123 更新时间:2023-12-03 10:53:31 24 4
gpt4 key购买 nike

我想要对空白进行精细控制,但仍然有可读的模板。

只是想通过简单的用例看看其他人的解决方案。

{{name}}
{{#if age}}
, {{age}}
{{/if}}

# outputs {{name}} , {{age}}
# desire: {{name}}, {{age}}

https://github.com/wycats/handlebars.js/issues/479 - 提交了一张已关闭的票。

最佳答案

跟踪历史 the pull request to add this feature看起来这是正确的语法:

<h4>
{{~#object~}}

Surrounding whitespace would be removed.

{{/object}}
</h4>

结果:
<h4>Surrounding whitespace would be removed.</h4>

还有这个语法只修剪前导空格:
<h4>
{{~#object}}

Only leading whitespace would be removed.

{{/object}}
</h4>

结果:
<h4>Only leading whitespace would be removed.
</h4>

关于whitespace - Handlebars ,空白控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15953293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com