1.9.0 • Published 7 years ago

karma-ember-preprocessor v1.9.0

Weekly downloads
603
License
-
Repository
github
Last release
7 years ago

karma-ember-preprocessor

Preprocessor to compile handlebars templates for ember.js on the fly

For more information on Karma see the homepage.

Requires Karma 0.9+

To use this with karma, first you will need to install it with npm

npm install karma-ember-preprocessor

Next you need to create a configuration file using karma init

module.exports = function(karma) {
    karma.set({
        basePath: 'js',

        files: [
          "vendor/jquery/jquery.min.js",
          "vendor/handlebars/handlebars.js",
          "vendor/ember/ember.js",
          "app.js",
          "tests/*.js",
          "templates/*.handlebars"
        ],

        logLevel: karma.LOG_ERROR,
        browsers: ['PhantomJS'],
        singleRun: true,
        autoWatch: false,

        frameworks: ["qunit"],

        plugins: [
            'karma-qunit',
            'karma-chrome-launcher',
            'karma-ember-preprocessor',
            'karma-phantomjs-launcher'
        ],

        preprocessors: {
            "**/*.handlebars": 'ember'
        }
    });
};

In case you want to use your custom Ember template compiler, you can specify path for it in the preprocessor configuration

module.exports = function(karma) {
    karma.set({

        ...

        emberPreprocessor: {
            compilerPath: 'bower_components/ember/ember-template-compiler.js'
        }
    });
};

It is also possible to specify a transform function to be used for the template name.

module.exports = function(karma) {
        karma.set({
            ...
            emberPreprocessor: {
                nameTransform: function(templateName) {
                    // your transform function code
                    return transformedName;
                }
            }
        });
    };

Processed templates will made available in Ember.TEMPLATES. For example:

templates/parent.hbs // => Ember.TEMPLATES['parent']
templates/parent/child.hbs // => Ember.TEMPLATES['parent/child']
templates/parent/child/index.hbs // => Ember.TEMPLATES['parent/child/index']
1.9.0

7 years ago

1.8.0

8 years ago

1.7.0

9 years ago

1.6.1

10 years ago

1.5.0

10 years ago

1.4.0

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.2

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago