Skip to content

Extend core classes #24

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions