Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does {{^ mean in handlebars

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

like image 547
Eric Avatar asked Mar 17 '23 01:03

Eric


1 Answers

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}}
like image 198
pborenstein Avatar answered Mar 20 '23 12:03

pborenstein