把手,空白控制 [英] Handlebars, whitespace control

查看:150
本文介绍了把手,空白控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



只是希望通过简单的用例来了解其他解决方案。

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

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

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

解决方案

遵循添加此功能的拉取请求的历史记录看起来像这是正确的语法:

 < h4> 
{{〜#object〜}}

周围的空白将被删除。

{{/ object}}
< / h4>

结果:

 < h4>周围的空白将被移除。< / h4> 

这种语法只修剪空白:

 < h4> 
{{〜#object}}

只有前导空格将被删除。

{{/ object}}
< / h4>

结果:

 < h4>只有前导空白符会被移除。 
< / h4>


i want fine control of whitespace but still have readable templates.

Just wanted to see if other's solution to by simple use case.

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

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

https://github.com/wycats/handlebars.js/issues/479 - submitted a ticket which was closed.

解决方案

Following the history from the pull request to add this feature it looks like this is the correct syntax:

<h4>
{{~#object~}}

Surrounding whitespace would be removed.

{{/object}}
</h4>

Result:

<h4>Surrounding whitespace would be removed.</h4>

There is also this syntax which trims only leading whitespace:

<h4>
{{~#object}}

Only leading whitespace would be removed.

{{/object}}
</h4>

Result:

<h4>Only leading whitespace would be removed.
</h4>

这篇关于把手,空白控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆