Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jayphelps/pomade.js

Decorate a JavaScript object by giving read-only access to a Delegate.
https://github.com/jayphelps/pomade.js

Last synced: 21 days ago
JSON representation

Decorate a JavaScript object by giving read-only access to a Delegate.

Awesome Lists containing this project

README

        

Pomade.js
===========
Work in progress...

Decorate a JavaScript object by giving read-only access to a `Delegate`.

## Usage
##### Handlebars

```javascript
var PersonDelegate = Pomade.Delegate.extend({
fullName: function () {
return this.get('firstName') + ' ' + this.get('lastName');
}
});

var template = Handlebars.compile(source);
var person = { firstName: 'Bilbo', lastName: 'Baggins' };
var delegate = PersonDelegate.create(person);
var html = template(delegate);
```

## Why?
People have their reasons. Maybe your design team wants to edit your templates and make custom properties but you don't want them to be able to screw with your actual JavaScript objects? Maybe you just really like abstraction.

## Compatibility
Works with pretty much any JavaScript object or library but I originally wrote it for templating with [Handlebars](https://github.com/wycats/handlebars.js/).