DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
      • Pages
        • Magic Tag Types
        • Scope and Context
        • Expressions
        • Template Acquisition
        • Helpers
        • Live Binding
      • Methods
        • from
        • registerConverter
        • registerHelper
        • registerPartial
        • registerSimpleHelper
        • safeString
      • Tags
        • {{expression}}
        • {{{expression}}}
        • {{#expression}}
        • {{/expression}}
        • {{^expression}}
        • {{>key}}
        • {{!expression}}
        • {{else}}
      • Expressions
        • Bracket Expression
        • Call Expression
        • Hash Expression
        • Helper Expression
        • KeyLookup Expression
        • Literal Expression
      • Key Operators
        • @at
        • ~compute
        • ./current
        • ../parent
        • %special
        • this
        • *variable
        • key
      • Helpers
        • {{#if expression}}
        • {{#unless expression}}
        • {{#each expression}}
        • {{#with expression}}
        • {{log}}
        • {{#is expressions}}
        • {{#switch expression}}
        • {{#case expression}}
        • {{#default}}
        • {{joinBase expressions}}
      • Types
        • getterSetter
        • helper
        • helperOptions
        • renderer
        • sectionRenderer
        • simpleHelper
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-stache
  • /
  • {{^expression}}
  • / On this page
    • {{^expression}}

      function

      Like {{#expression}}, but renders the opposite subsection depending on the type of expression or the expression's return value.

      • source

      {{^EXPRESSION}}FN{{else}}INVERSE{{/key}}

      Works just like {{#expression}}, but renders INVERSE when it would have rendered the FN block and vice-versa.

      For example:

      {{^ isOver18(person) }} Can't Vote {{/isOver18}}
      

      Renders Can't Vote if isOver18(person) returns falsey.

      Parameters

      1. EXPRESSION {Literal Expression|KeyLookup Expression|Call Expression|Helper Expression}:

        An expression type. Behavior depends on the type of expression:

        • KeyLookup Expression and Call Expressions:
          • renders FN with falsey values and empty lists.
          • renders INVERSE with truthy values or each item in a list.
        • Helper Expressions: switch the options.fn and options.inverse.

      Use

      Inverted sections match falsey values. An inverted section syntax is similar to regular sections except it begins with a caret rather than a pound. If the value referenced is falsey, the section will render. For example:

      The template:

      <ul>
          {{#friends}}
              </li>{{name}}</li>
          {{/friends}}
          {{^friends}}
              <li>No friends.</li>
          {{/friends}}
      </ul>
      

      And data:

      {
          friends: []
      }
      

      Results in:

      <ul>
          <li>No friends.</li>
      </ul>
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.