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

      typedef
      • source

      {{ method( [EXPRESSION...] ) }}

      Calls method with zero or many arguments where each argument is a comma separated EXPRESSION.

      method(1,key,hashProp=hashValue,call(),helper expression)
      

      Parameters

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

        An expression that will be passed as an argument to method.

      Use

      A call expression calls a function looked up in the scope followed by the helpers scope. It looks like:

      Template:
          <h1>{{pluralize(type,ages.length)}}</h1>
      
      Data:
          {
            pluralize: function(type, count){
              return type+(count === 1 ? "" : "s")
            },
            todos: new List([22,32,42]),
            type: "age"
          }
      
      Result:
          <h1>Ages</h1>
      

      Call expression arguments are comma (,) separated. If a Hash expression is an argument, an object with the hash properties and values will be passed. For example:

      Template:
          <h1>{{pluralize(word=type count=ages.length)}}</h1>
      
      Data:
          {
            pluralize: function(options){
              return options.word+(options.count === 1 ? "" : "s")
            },
            todos: new List([22,32,42]),
            type: "age"
          }
      
      Result:
          <h1>Ages</h1>
      

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