Skip to content

Instantly share code, notes, and snippets.

View davewasmer's full-sized avatar

Dave Wasmer davewasmer

View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
didRender() {
this._super();
Ember.run.later(() => {
this.set('tagName', 'h1')
console.log(this.get('tagName'));
this.rerender();
import Ember from 'ember';
export default Ember.Controller.extend({
setupExperiment: function() {
// Attaching comment to post
//let pictureComment = this.store.createRecord('picture-comment');
//let videoPost = this.store.createRecord('video-post', {
// comments: [ pictureComment ]
//});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
someArray: [ 'one', 'two', 'three' ],
anotherArray: [ 'one', 'four' ],
arrayOfArrays: function() {
return [ this.get('someArray'), this.get('anotherArray') ];
@davewasmer
davewasmer / index.hbs
Created July 23, 2015 20:54
Form validation: template inlined error messages
<div class=”form-group”>
<label>Email address</label>
{{input type=”email” class=”form-control” placeholder=”Email” value=model.email}}
{{#error-for model=model field='email' matches='BadFormat'}}
Whoops, you’ll need your email to sign up. Looks like you missed it here.
{{/error-for}}
</div>
@davewasmer
davewasmer / form-controller.js
Created July 23, 2015 20:49
Form validation: inlined error messages
FormController = Ember.Controller.extend({
validation: {
email: {
presence: true,
format: {
type: 'email',
message: 'Whoops, you’ll need your email to sign up. Looks like you missed it here.'
}
}
@davewasmer
davewasmer / form-controller.js
Created July 23, 2015 20:26
Form validation: validation rules
FormController = Ember.Controller.extend({
validation: {
email: {
presence: true,
format: 'email'
}
}
});
@davewasmer
davewasmer / index.hbs
Last active August 29, 2015 14:25
Form validation: typical example
<div class=”form-group”>
<label>Email address</label>
{{input type=”email” class=”form-control” placeholder=”Email” value=model.email}}
{{#if model.errors.email}}
<p class=”error-block”>{{model.errors.email}}</p>
{{/if}}
</div>
@davewasmer
davewasmer / addons.txt
Created June 30, 2015 03:48
Starter addons
ember-cli-build-notifications
ember-cli-deploy
ember-cli-document-title
ember-cli-fontcustom
ember-cli-mocha
ember-cli-sass
ember-cli-velocity
ember-data-route
ember-moment
ember-wormhole
// In lib/models/projects ...
Project.prototype.addIfAddon = function(addonPath, parentAddonName) {
var pkgPath = path.join(addonPath, 'package.json');
if(fs.existsSync(pkgPath)) {
var addonPkg = require(pkgPath);
var addonName = addonPkg.name + '@' + addonPkg.version
var keywords = addonPkg.keywords || [];
var addonConfig;
@davewasmer
davewasmer / gist:627db56cde978f277cc2
Created May 15, 2014 04:06
Sass Color Palette Generator
// See it in action:
// http://codepen.io/anon/pen/Hwemg
// Creates a map called `$palettes` and a function called `palette`.
// Call `palette` with a color name and optional tint:
//
// .my-div {
// color: palette(primary, lighter);
// }
//