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

      typedef

      The getterSetter argument passed to registerConverter.

      • source

      Object

      An object with a get and set method that get converted to a two-way helper.

      stache.registerConverter("numberToString", {
       get: function(fooCompute) {
          return "" + fooCompute();
       },
       set: function(newVal, fooCompute) {
          fooCompute(+newVal);
       }
      });
      

      A getterSetter object provides:

      • A get method that returns the value of the left value given the arguments passed on the right.
      • a set method that updates one or multiple of the right arguments computes given a new left value.

      Options

      • get {function(args...)}:

        Takes the arguments from a Call Expression and returns a value.

        An argument is a compute if the argument has been marked with a tilde (~) prefix, otherwise the value of the argument is the same as the value of the corresponding scope property. At least one argument should be a compute so set can update the value.

      • set {function(setValue, args...)}:

        Takes the new value of the left side of a {(two-way)} binding followed by the other arguments to the Call Expression. This should change one of the compute arguments.

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