Giter VIP home page Giter VIP logo

ember-cpm's Introduction

Ember-CPM

Build Status

Computed Property Macros for Ember

Requirements

Ember. Versions between 0.9.8 and 1.1 should work fine. (If you're running Ember 0.9.x and want the CP macros from Ember 1.0, the ember_09 branch has them.)

Installation

Just add index.js to your page after Ember but before your app.

Provided Macros

  • among -- returns true if the original value is among the given literals (testing using ===)
  • encodeURIComponent -- calls encodeURIComponent on the original value
  • encodeURI -- calls encodeURI on the original value
  • fmt -- pass the original values into a format-string
  • htmlEscape -- escapes the original value with Handlebars.Utils.escapeExpression and wraps the result in a Handlebars.SafeString (since it's now safe)
  • ifNull -- fall back on a default value
  • notAmong -- inverse of among
  • notEqual -- inverse of the built-in equal macro
  • notMatch -- inverse of the built-in match macro
  • promise -- wraps the original value in an already-resolved promise
  • safeString -- wraps the original value in a Handlebars.SafeString
  • join -- joins the supplied values together with a provided sepatator

Examples

Person = Ember.Object.extend({

  name: null,

  handedness: null,

  greeting: null,

  handle: EmberCPM.Macros.ifNull('name', 'Anonymous'),

  greeting: EmberCPM.Macros.fmt('name', 'greeting', '%@ says, "%@!"'),

  canUseLeftHand: EmberCPM.Macros.among('handedness', 'left', 'ambidextrous'),

  notNamedJohn: EmberCPM.Macros.notMatch('name', /\bJohn\b/)

});

Ember.computed

If you would prefer to use Ember.computed.{macro} instead of EmberCPM.Macros.{macro} (for the sake of uniform access), simply call EmberCPM.install() before your application code.

ember-cpm's People

Contributors

jamesarosen avatar jimsynz avatar joefiorini avatar gunn avatar kencheeto avatar lukemelia avatar

Watchers

David J. Hamilton avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.