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
  • /
  • Hash Expression
  • / On this page
    • Hash Expression

      typedef
      • source

      [PROPERTY_NAME=EXPRESSION ]+

      A sequence of one or more property names and their values as another expression like:

      prop1=1 prop2=key prop3=callExpression()
      

      In a Call Expression, Hash expressions create an object argument with the specified PROPERTY_NAME properties and EXPRESSION values.

      The following template:

      {{ method( age=5 first=person.firstName last=person.getLastName() ) }}
      

      Might call method with:

      {age: 5, first: "Justin", last: "Meyer"}
      

      In a Helper Expression, Hash expressions add to the helperOptions's hash object with the specified PROPERTY_NAME properties and EXPRESSION values.

      The following template:

      {{ method age=5 first=person.firstName last=person.getLastName() }}
      

      Might call method with:

      {
          hash: {age: 5, first: compute("Justin"), last: compute("Meyer")}
      }
      

      Parameters

      1. PROPERTY_NAME {String}:

        The property name on the call expression argument object or helperOptions's hash object.

      2. EXPRESSION {Literal Expression|KeyLookup Expression|Call Expression}:

        An expression that provides a value for the property name.

      Use

      A hash expression specifies a property value on a object argument in a call expression and property value on the the hash object in a helper expression's helperOptions argument.

      For example, in a call expression:

      Template:
          {{methodA(prop=key)}}
          {{methodB(propX=key propY='literal', propZ=5)}}
      Data:
          {
            methodA: function(arg){},
            methodB: function(arg1, arg2){},
            key: compute("value")
          }
      
      • methodA will be called with {prop: "value"} as arg.
      • methodB will be called with {propX: "value", propY: 'literal'} as arg1 and {propZ: 5} as arg2

      In a helper expression:

      Template:
          {{methodA prop=key}}
          {{methodB(propX=key propY='literal' propZ=5)}}
      Data:
          {
            methodA: function(options){},
            methodB: function(options){},
            key: compute("value")
          }
      
      • methodA will be called with {prop: compute("value")} as options.hash.
      • methodB will be called with {propX: "value", propY: 'literal', propZ: 5} as options.hash.

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