Skip to content

Instantly share code, notes, and snippets.

@saadtazi
saadtazi / mstl.js
Created September 27, 2013 01:29
requireJS plugin that compiles mustache template. Templates are added and automatically registered in your compiled js file using r.js.
/*
* requirejs plugin that loads mustache templates from the baseUrl and registers it in can.view
* Optimize/compiles/minifies the templates when the requirejs optimizer is run
* usage:
* require([
..,
'mustl!path/to/mustache/tmp.mustache' // no need to add a var in callback function for your template
], function () {})
*/
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
can.Model.List.prototype.filter = function(cb) {
var res = [];
debugger;
this.each(function(amodel, pos, models) {
var ares = cb.call(amodel, pos, models);
if (ares === true) {res.push(amodel)}
});
return res
}
@saadtazi
saadtazi / README.md
Last active December 12, 2015 08:09
canjs google analtyics plugin

Usage

A canjs Control that setup Google Analytics (injects JS) and can automatically:

  • track hashChange (on or off) as pageView
  • track any can.Model / Observe / Model.List / Observe.List events as Google Analytics events

Observe Event