Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend core classes #24

Open
ghost opened this issue May 10, 2014 · 0 comments
Open

Extend core classes #24

ghost opened this issue May 10, 2014 · 0 comments

Comments

@ghost
Copy link

ghost commented May 10, 2014

As with most projects I don't like modifying core files (although this project does present a unique case to do it). My proposal is as follows.

Split core directory into two structures

core/_boiler_.js
core/helpers/_helpers_.js

extend/_boiler_.js
extend/helpers/_helpers_.js

The Helpers extended module would look like this :

define(function(require) {

    var Helpers = require('core/helpers/_helpers_');

    return _.extend(Helpers, {

    });
});

The same would go for _boiler_. I would have these two modules configured in main.js in the require config to always load from extend\*. All new modules can now be created in extend allowing overrides of core files, helper files and new core extensions to be added without touching core itself.

Implement a Backbone style 'extend' static on core classes

So I stole the Backbone extend function and placed it into boilerplate. I have then modified all core classes to use the extend method as a static extend.

This allows

define(function(require) {

    var Boiler = require('boiler');

    return Boiler.ViewTemplate.extend({

        someMethod : function() {}

    });
});

I 'd like to know your thoughts, this structure works very well for me and I'm sure it'd work well for most that have used Boilerplate.js to bootstrap their projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants