karma-lodash-template-preprocessor

0.1.2 • Public • Published

karma-lodash-template-preprocessor

Karma preprocessor to compile Lo-Dash templates on the fly.

Installation

npm install karma-lodash-template-preprocessor --save-dev

Configuration

Following code shows the default configuration.

// karma.conf.js
module.exports = function( config ) {
  config.set({
    preprocessors: {
      "**/*.template.js": [ "lodash" ]
    },

    lodashPreprocessor: {
      // Template data. You can use function, which returns object
      data: {
        "this will be passed": "to _.template as second argument"
      },
      // Options passed to the _.template function as third argument:
      options: {
        interpolate: /regexp/,
        variable: "info"
        // Full list: http://lodash.com/docs#template
      },

      // Filename transform function ("file.template.js" > "file.js"):
      transformPath: function( path ) {
        return path.replace( /\.template\./i, "." );
      }
    }
  });
};

Package Sidebar

Install

npm i karma-lodash-template-preprocessor

Weekly Downloads

38

Version

0.1.2

License

MIT

Last publish

Collaborators

  • deltaidea