This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Front-end Boilerplate</title> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<link rel="icon" href="favicon.ico"> | |
</head> | |
<body> | |
<script id="list-item-template" type="text/x-handlebars-template"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ajaxError(function(evt, xhr, options) { | |
var responseText = xhr.responseText || 'The server did not respond on time.'; | |
var status = xhr.status || 408; | |
var statusText = xhr.statusText || 'Request Timeout'; | |
var message = { | |
text: responseText, | |
code: status, | |
url: xhr.url, | |
status: statusText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ensureModules = (app, modules) -> | |
_.each app.submodules, (module) -> | |
if (modules.indexOf(module.moduleName) == -1 && module.started) | |
console.log 'stopping module:', module.moduleName | |
module.stop() | |
_.each(app.submodules, (module) -> | |
if (modules.indexOf(module.moduleName) > -1 && !module.started) | |
console.log 'starting module:', module.moduleName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('sum', function() { | |
var args = _.flatten(arguments); | |
var sum = 0; | |
var i = args.length - 1; | |
while (i--) { | |
sum += _.parseInt(args[i]) || 0; | |
} | |
return Number(sum); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var render = function render(tplEl, htmlEl, context) { | |
var template = Handlebars.compile($(tplEl).text()); | |
context = context || {}; | |
return $(htmlEl).html(template(context)); | |
}; | |
render('#tpl-demo', '#doc', { name: 'John Doe' }); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('deepSum', function(source, key) { | |
var result; | |
if (typeof key === 'string') { | |
if (key.split('.').length > 1) { | |
source = _.pluckDeep(source, key); | |
} else { | |
source = _.pluck(source, key); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
'dist/assets/js/plugins.js': 'src/plugins.coffee' | |
options: | |
transform: ['caching-coffeeify'] | |
browserifyOptions: | |
extensions: '.coffee' | |
paths: ['./src', './src/app'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import dependencies | |
dependencies = {} | |
dependencies.Debugger = require 'lib/debugger' | |
# include vendors | |
$ = require 'jquery' | |
_ = require 'underscore' | |
Backbone = require('backbone').$ = $ | |
Marionette = require 'backbone.marionette' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection extends Backbone.Collection | |
model: User | |
query: (query) -> | |
query = new RegExp query, 'gi' | |
filtered = @filter (item) -> | |
state = !!item.attributes.details.firstName.match(query) | |
return state | |
return new Collection filtered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (options) -> | |
# | |
# <- i want to do something like app.use here | |
# when im mounting this middleware | |
# | |
return (req, res, next) -> | |
# req.app is available here, but thats too late, i dont | |
# want the app instance in every request, i only want | |
# it when i mount the middleware | |
res.send('OK') |