Some thoughts and ideas on best practices building Ember apps after 2 years building and maintaining 6+ apps. This is less about the obvious best practices, like use ember-cli, and more along the lines of when to use what technique. As with every best practice there are exceptions to every rule.
| /* bling.js */ | |
| window.$ = document.querySelector.bind(document); | |
| window.$$ = document.querySelectorAll.bind(document); | |
| Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); }; | |
| NodeList.prototype.__proto__ = Array.prototype; | |
| NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); }; |
| <form id="contact-form" action="//formspree.io/[email protected]" method="post"> | |
| <input type="text" name="Name" placeholder="Name" required> | |
| <input type="email" name="Email" placeholder="Email" required> | |
| <textarea name="Message" cols="30" rows="6" placeholder="Message" required></textarea> | |
| <!-- CONFIG --> | |
| <input class="is-hidden" type="text" name="_gotcha"> | |
| <input type="hidden" name="_subject" value="Subject"> | |
| <input type="hidden" name="_cc" value="[email protected]"> | |
| <!-- /CONFIG --> | |
| <input class="submit" type="submit" value="Send"> |
| <script type="text/javascript"> | |
| (function () { | |
| "use strict"; | |
| // once cached, the css file is stored on the client forever unless | |
| // the URL below is changed. Any change will invalidate the cache | |
| var css_href = './index_files/web-fonts.css'; | |
| // a simple event handler wrapper | |
| function on(el, ev, callback) { | |
| if (el.addEventListener) { | |
| el.addEventListener(ev, callback, false); |
| header | |
| .row.nav-header | |
| .container | |
| .nav-header__logo | |
| img src="/" | |
| nav.nav-header__menu |
| module ImagesHelper | |
| # Acts as a thin wrapper for image_tag and generates an srcset attribute for regular image tags | |
| # for usage with responsive images polyfills like picturefill.js, supports asset pipeline path helpers. | |
| # | |
| # image_set_tag 'pic_1980.jpg', { 'pic_640.jpg' => '640w', 'pic_1024.jpg' => '1024w', 'pic_1980.jpg' => '1980w' }, sizes: '100vw', class: 'my-image' | |
| # | |
| # => <img src="/assets/ants_1980.jpg" srcset="/assets/pic_640.jpg 640w, /assets/pic_1024.jpg 1024w, /assets/pic_1980.jpg 1980w" sizes="100vw" class="my-image"> | |
| # | |
| def image_set_tag(source, srcset = {}, options = {}) | |
| srcset = srcset.map { |src, size| "#{path_to_image(src)} #{size}" }.join(', ') |
| /* | |
| This is for demonstration purposes. Ideally, you should never use the star selector. | |
| I recommend that you use this early on in your development, and then once you've established | |
| your HTML element palette, go back and replace * with a comma-separated list of your | |
| tag names. Additionally, the !important shouldn't have to be used, but I'm leaving it here | |
| because some enterprising goons will probably copy and paste this directly into their project - | |
| the !important will ensure these settings override other attempts that were either never | |
| deleted or are part of an installed CSS file the user is unaware of. | |
| */ | |
| * { |
| // Created by Max Luster (@maxluster) | |
| // Usage instructions at https://bugsnag.com/blog/responsive-typography-with-chained-media-queries | |
| // Requires SASS >= 3.3 | |
| // Enhanced by Breakpoint 2.4.x and Compass 1.0 (alpha) | |
| // For SASS 3.2.x support, use https://gist.github.com/maxluster/c9ecc6e4a6770e507c2c | |
| // Provides a simplified syntax for chaining media queries across named or numeric breakpoints | |
| @mixin responsive($properties, $default-value, $responsive-values){ | |
| // No named breakpoints by default |
This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.
I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.
Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.
-
Data Down / Actions Up
- http://emberjs.jsbin.com/nayaho/edit?html,js - Interdependent select boxes. No observers.
- http://ember-twiddle.com/2d7246875098d0dbb4a4 - One Way Input
-
Plain JSBin's
-
Ember Version Base JSBin's