最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does {{^ mean in handlebars - Stack Overflow

programmeradmin3浏览0评论

I have a handlebars template that contains:

{{^is mymodel.someproperty}}

I don't understand what the significance of the caret symbol is. I've searched around, the only place I'm seeing it is on Handlebars Expressions

It's used like so:

{{#each nav}}
  <a href="{{url}}">
    {{#if test}}
      {{title}}
    {{^}}
      Empty
    {{/if}}
  </a>
{{~/each}}

I have a handlebars template that contains:

{{^is mymodel.someproperty}}

I don't understand what the significance of the caret symbol is. I've searched around, the only place I'm seeing it is on Handlebars Expressions

It's used like so:

{{#each nav}}
  <a href="{{url}}">
    {{#if test}}
      {{title}}
    {{^}}
      Empty
    {{/if}}
  </a>
{{~/each}}

What does "{{^" mean in handlebars? It sort of looks like a .NOT. or .ELSE. or something like that.

-Eric

Share Improve this question asked May 14, 2015 at 18:14 EricEric 3,2338 gold badges38 silver badges71 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

The reason it's not in the handlebars doc is because it's a mustache construct called an Inverted Section.

See: https://mustache.github.io/mustache.5.html#Inverted-Sections

{{#repo}}
  <b>{{name}}</b>
{{/repo}}
{{^repo}}
  No repos :(
{{/repo}}

... disabling inverse operations such as {{^foo}}{{/foo}} unless fields are explicitly included in the source object._

http://handlebarsjs./reference.html

http://handlebarsjs./expressions.html

发布评论

评论列表(0)

  1. 暂无评论