Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/jayphelps/pomade.js
- Owner: jayphelps
- Created: 2014-02-26T07:51:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-02-26T08:04:43.000Z (over 10 years ago)
- Last Synced: 2023-03-22T22:37:17.785Z (over 1 year ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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/).