admin管理员组文章数量:1336699
{{#Version}} Product Version={{{Version}}}{{Version}}
I am pletely new to mustache.js, apologies if the question is not clear.
In the above line i am able to get Product Version if the version is not empty but i also wanted to be able to get Product Version even when Version is empty.
Mustache will drop 'Product Version' from the output if Version is empty.
Product Version =''
{{#Version}} Product Version={{{Version}}}{{Version}}
I am pletely new to mustache.js, apologies if the question is not clear.
In the above line i am able to get Product Version if the version is not empty but i also wanted to be able to get Product Version even when Version is empty.
Mustache will drop 'Product Version' from the output if Version is empty.
Product Version =''
Share
Improve this question
asked Mar 14, 2017 at 23:31
Sri Sri
491 silver badge7 bronze badges
1
- Can you provide an accurate representation of the object you are rendering? I suspect whatever "Product Version" is has a length of zero when it is empty. – IronAces Commented Mar 16, 2017 at 8:00
2 Answers
Reset to default 4This way you can handle empty values so you still get ProductVersion
:
Product Version={{#Version}}{{{Version}}}{{/Version}}{{^Version}}''{{/Version}}
Where {{^Version}}{{/Version}}
is called an inverted section and will be rendered if the value of that section's tag is null, undefined, false, falsy or an empty list. As it is explained in the doc.
You can show the version if it is not empty and show anything otherwise:
{{#Version}}<b>{{Version}}</b>{{/Version}} {{^Version}}Anything{{/Version}}
本文标签: javascriptMustachejs should be able to handledisplay empty stringStack Overflow
版权声明:本文标题:javascript - Mustache.js should be able to handledisplay empty string - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742419661a2471400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论