Skip to content

Instantly share code, notes, and snippets.

@engram-design
Last active December 17, 2015 02:58
Show Gist options
  • Save engram-design/5539338 to your computer and use it in GitHub Desktop.
Save engram-design/5539338 to your computer and use it in GitHub Desktop.

Revisions

  1. engram-design revised this gist May 8, 2013. 2 changed files with 3 additions and 1 deletion.
    2 changes: 2 additions & 0 deletions config.js
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,14 @@ require.config({
    jquery: '../vendor/js/libs/jquery',
    underscore: '../vendor/js/libs/lodash.underscore',
    backbone: '../vendor/js/libs/backbone',
    handlebars: '../vendor/js/libs/handlebars',

    marionette: '../vendor/js/libs/backbone.marionette',
    text: '../vendor/js/libs/text',
    hbars: '../vendor/js/libs/hbars'
    },
    shim: {
    handlebars: { exports: 'Handlebars' },
    marionette: {
    deps: ['jquery', 'underscore', 'backbone'],
    exports: 'Marionette'
    2 changes: 1 addition & 1 deletion grunt.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    module.exports = function(grunt) {
    grunt.initConfig({

    handlebars: {
    handlebars: {
    "dist/debug/templates.js": ["app/templates/**/*.html"]
    },

  2. engram-design revised this gist May 8, 2013. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions grunt.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    module.exports = function(grunt) {
    grunt.initConfig({

    handlebars: {
    "dist/debug/templates.js": ["app/templates/**/*.html"]
    },

    requirejs: {
    mainConfigFile: "app/config.js",
    out: "dist/debug/require.js",
    name: "config",
    wrap: false,
    paths: {
    handlebars: "../vendor/js/libs/handlebars.runtime"
    }
    }
    });

    grunt.registerTask("debug", "handlebars requirejs");
    };
  3. engram-design revised this gist May 8, 2013. 4 changed files with 28 additions and 28 deletions.
    22 changes: 11 additions & 11 deletions config.js
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    require.config({
    deps: ['main'],
    paths: {
    jquery: '../vendor/js/libs/jquery',
    underscore: '../vendor/js/libs/lodash.underscore',
    backbone: '../vendor/js/libs/backbone',

    paths: {
    jquery: '../vendor/js/libs/jquery',
    underscore: '../vendor/js/libs/lodash.underscore',
    backbone: '../vendor/js/libs/backbone',
    marionette: '../vendor/js/libs/backbone.marionette',
    text: '../vendor/js/libs/text',
    hbars: '../vendor/js/libs/hbars'
    },
    text: '../vendor/js/libs/text',
    hbars: '../vendor/js/libs/hbars'
    },
    shim: {
    marionette: {
    deps: ['jquery', 'underscore', 'backbone'],
    exports: 'Marionette'
    }
    deps: ['jquery', 'underscore', 'backbone'],
    exports: 'Marionette'
    }
    }
    });
    22 changes: 11 additions & 11 deletions hbars.js
    Original file line number Diff line number Diff line change
    @@ -10,17 +10,17 @@ define(['handlebars'], function(Handlebars) {
    }
    else {
    var JST = window.JST ? window.JST : {};
    var path = 'app/' + name + '.html'; // TODO: add path into config options
    if (JST[path]) {
    // Grunt.js pre-compiles templates into JST[]
    onload(Handlebars.template(JST[template]));
    } else {
    // use text.js plugin when loading templates during development
    parentRequire(['text!' + name + '.html'], function(raw) {
    onload(Handlebars.compile(raw));
    });
    }
    var path = 'app/' + name + '.html'; // TODO: add path into config options

    if (JST[path]) {
    // Grunt.js pre-compiles templates into JST[]
    onload(Handlebars.template(JST[template]));
    } else {
    // use text.js plugin when loading templates during development
    parentRequire(['text!' + name + '.html'], function(raw) {
    onload(Handlebars.compile(raw));
    });
    }
    }
    }
    };
    6 changes: 3 additions & 3 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@ define([
    ], function(app) {
    var Module = app.module('Module');

    Module.Views = {};
    Module.Views = {};

    Module.Views.Index = Backbone.Marionette.ItemView.extend({
    template: app.templates.ModuleTemplate
    });
    template: app.templates.ModuleTemplate
    });

    return Module;
    });
    6 changes: 3 additions & 3 deletions templates.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    define(function(require){
    return {

    // Layout/Region templates
    AppLayout: require('hbars!templates/layout_app'),
    // Layout/Region templates
    AppLayout: require('hbars!templates/layout_app'),

    ModuleTemplate: require('hbars!templates/module_template')
    };
    };
    });
  4. engram-design revised this gist May 8, 2013. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    define([
    'marionette',
    'templates'
    'templates'
    ], function(Marionette, Templates) {

    var app = new Marionette.Application({
    root: '/',
    templates: Templates
    });
    return app;
    var app = new Marionette.Application({
    root: '/',
    templates: Templates
    });
    return app;
    });
  5. engram-design revised this gist May 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion templates.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ define(function(require){
    return {

    // Layout/Region templates
    AppLayout: require('hbars!templates/layout_app'),
    AppLayout: require('hbars!templates/layout_app'),

    ModuleTemplate: require('hbars!templates/module_template')
    };
  6. engram-design created this gist May 8, 2013.
    12 changes: 12 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    define([
    'marionette',
    'templates'
    ], function(Marionette, Templates) {

    var app = new Marionette.Application({
    root: '/',
    templates: Templates
    });

    return app;
    });
    18 changes: 18 additions & 0 deletions config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    require.config({
    deps: ['main'],
    paths: {
    jquery: '../vendor/js/libs/jquery',
    underscore: '../vendor/js/libs/lodash.underscore',
    backbone: '../vendor/js/libs/backbone',

    marionette: '../vendor/js/libs/backbone.marionette',
    text: '../vendor/js/libs/text',
    hbars: '../vendor/js/libs/hbars'
    },
    shim: {
    marionette: {
    deps: ['jquery', 'underscore', 'backbone'],
    exports: 'Marionette'
    }
    }
    });
    27 changes: 27 additions & 0 deletions hbars.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    define(['handlebars'], function(Handlebars) {
    var buildMap = {};

    return {
    load: function (name, parentRequire, onload, config) {
    if (config.isBuild) {
    var fsPath = config.dirBaseUrl + '/' + name + '.html'; // TODO - add ext into config options
    buildMap[name] = nodeRequire('fs').readFileSync(fsPath).toString();
    onload();
    }
    else {
    var JST = window.JST ? window.JST : {};
    var path = 'app/' + name + '.html'; // TODO: add path into config options

    if (JST[path]) {
    // Grunt.js pre-compiles templates into JST[]
    onload(Handlebars.template(JST[template]));
    } else {
    // use text.js plugin when loading templates during development
    parentRequire(['text!' + name + '.html'], function(raw) {
    onload(Handlebars.compile(raw));
    });
    }
    }
    }
    };
    });
    13 changes: 13 additions & 0 deletions module.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    define([
    'app'
    ], function(app) {
    var Module = app.module('Module');

    Module.Views = {};

    Module.Views.Index = Backbone.Marionette.ItemView.extend({
    template: app.templates.ModuleTemplate
    });

    return Module;
    });
    9 changes: 9 additions & 0 deletions templates.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    define(function(require){
    return {

    // Layout/Region templates
    AppLayout: require('hbars!templates/layout_app'),

    ModuleTemplate: require('hbars!templates/module_template')
    };
    });