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
  • /
  • @at
  • / On this page
    • @at

      typedef

      Return whatever value is at a key, regardless if it's a function or a compute.

      • source

      @key

      Lookup a key value in the scope and return whatever is there.

      <paginator {next}="@loadNext"/>
      

      key@prop

      Lookup prop property on key and return whatever is there.

      <grid {get-data}="Todo@getList"/>
      

      Use

      The following illustrates what some@key would return given different data structures:

      // A non-observable JS object:
      {some: {key: "value"}}
         //-> "value"
      
      // A non-observable JS object w/ a function at the end
      {some: {key: function(){ return "value"; }}}
         //-> function(){ return "value"; }
      
      // A non-observable JS object with intermeidate functions:
      {some: function(){ return {key: "value"}}}
         //-> "value"
      
      // A observable can-map
      {some: new Map({key: "value"})}
         //-> "value"
      
      // A method on an observable can-map that reads observables
      var Some = Map.extend({key: function(){ return this.attr("value")}})
      {some: new Some({value: "value"})}
         //-> function(){ return this.attr("value")}
      

      Where some@key returns a function, that function is "bound" via .bind(context) to the parent object. This means that calling the function will have this set to what is expected.

      If the AT key is used at the start of a key like:

      {{method(@key)}}
      

      This will return whatever is at the key property on the first context in the scope to have a non-undefined key value.

      The AT key can be used multiple times within a value lookup expression like:

      {{method(models@Todo@getList)}}
      

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