ampersandjs
TRANSCRIPT
@drewfyock
Core Team
@henrikjoreteg@philip_roberts @lancestout @lynnandtonic
@lukekarrys @wraithgar @kamilogorek
@drewfyock
var Person = AmpersandState.extend({
props: {
firstName: 'string',
lastName: 'string'
},
session: {
signedIn: ['boolean', true, false],
},
derived: {
fullName: {
deps: ['firstName', 'lastName'],
fn: function () {
return this.firstName + ' ' + this.lastName;
}
}
}
});
@drewfyock
ampersand-collection / ampersand-subcollection / ampersand-rest-collection
ampersand-collection
@drewfyock
var WidgetCollection = require('./mycollection');
var SubCollection = require('ampersand-subcollection');
var widgets = new WidgetCollection();
widgets.fetch();
var favoriteWidgets = new SubCollection(widgets, {
where: {
awesome: true
},
comparator: function (model) {
return model.rating;
}
});
@drewfyock
ampersand-rest-collectionampersand-collection & ampersand-collection-rest-mixin & ampersand-collection-underscore-mixing
@drewfyock
var PersonRowView = AmpersandView.extend({
template: "<li><span data-hook='name'></span><span data-hook='age'></span><a data-
hook='edit'>edit</a></li>",
events: {
"click [data-hook=edit]": "edit"
},
bindings: {
"model.name": {
type: 'text',
hook: 'name'
},
"model.age": {
type: 'text',
hook: 'age'
}
},
subviews: {
personSubview: {...}
},
edit: function () {...}
});
@drewfyock
var pageSwitcher = new ViewSwitcher(pageContainer, {
waitForRemove: true,
hide: function (oldView, newView, cb) {
oldView.el.classList.add('animateOut');
setTimeout(cb, 1000);
},
show: function (newView, oldView) {
document.title = newView.pageTitle || 'app name';
document.body.scrollTop = 0;
app.currentPage = newView;
newView.el.classList.add('animateIn');
}
});
@drewfyock
var FormView = require('ampersand-form-view');
var InputView = require('ampersand-input-view');
var AwesomeFormView = new FormView({
submitCallback: function (obj) {
console.log('form submitted! Your data:', obj);
},
validCallback: function (valid) {
if (valid) {
console.log('The form is valid!');
} else {
console.log('The form is not valid!');
}
},
fields: [
new InputView({
name: 'client_name',
label: 'App Name',
placeholder: 'My Awesome App',
value: 'hello',
tests: [
function (val) {
if (val.length < 5) return "Must be 5+ characters.";
}
]
})
]
});
@drewfyock
var View = require('ampersand-view');
var templates = require(‘../templates’);
module.exports = View.extend({
template: templates.includes.person,
bindings: {
'model.fullName': '[data-hook=name]',
'model.avatar': {
type: 'attribute',
hook: 'avatar',
name: 'src'
},
'model.editUrl': {
type: 'attribute',
hook: ‘action-edit',
name: 'href'
},
'model.viewUrl': {
type: 'attribute',
hook: 'name',
name: 'href'
}
},
events: {
'click [data-hook=action-delete]': 'handleRemoveClick'
},
handleRemoveClick: function () {
this.model.destroy();
}
});
@drewfyock
var AppRouter = AmpersandRouter.extend({
routes: {
"help": "help", // #help
"search/:query":"search", // #search/kiwis
"search/:query/p:page": "search" // #search/kiwis/p7
},
help: function() {...},
search: function(query, page) {...}
});
@drewfyock
ampersand-collection-rest-mixin
ampersand-collection-underscore-mixin
ampersand-domthing-mixin
@drewfyock
ampersand-collection-rest-mixin
ampersand-collection-underscore-mixin
ampersand-domthing-mixin
ampersand-react-mixin
@drewfyock
Starting a new app
Generating form, view, model or collection
Generating models from JSON
@drewfyock
Starting a new app
Generating form, view, model or collection
Generating models from JSON
Generating forms from models
@drewfyock
Starting a new app
Generating form, view, model or collection
Generating models from JSON
Generating forms from models
Configuring the generated code
@drewfyock
// .ampersandrc
{
// default framework to be prompted with, options are express or hapi
framework: 'hapi',
indent: 4,
view: '', // default template
router: '', // default template
model: '', // default template
page: '', // default template
collection: '', // default template
clientfolder: 'client',
viewfolder: 'views',
pagefolder: 'pages',
modelfolder: 'models',
formsfolder: 'forms',
collectionfolder: 'models',
// whether to create collection when making a model
makecollection: true,
// if it was called without the 'gen' argument we're building a new one
// so we won't look for an application root
approot: '', // starts walking up folders looking for package.json
f: false, // overwrite
force: false, // overwrite flag, longform
quotes: 'single' // can be 'single' or 'double'
};
@drewfyock
Why we chose Ampersand at Bessemer:
CommonJS by default
Flexible and modular
Based on Backbone
Just the right amount of magic
Incredibly easy to integrate with Express or Hapi
Support on Gitter
@drewfyock
Why you might not choose Ampersand:
Still fairly new
Moonboots - Jade
Not as “full featured" as Angular or Ember
May have to roll-your-own for specific components
@drewfyock
http://ampersandjs.com/contribute
http://issues.ampersandjs.com
https://github.com/ampersandjs
@drewfyock
Thank You@drewfyock @mikesabatini
http://bessemeralliance.com