karma-pug2js-preprocessor

0.1.0 • Public • Published

karma-pug2js-preprocessor

Preprocessor for converting pug template files to javascript.

Forked from karma-ng-jade2js-preprocessor

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.jade': ['pug2js']
    },
 
    files: [
      '*.js',
      '*.jade',
      // if you wanna load template files in nested directories, you must use this
      '**/*.jade'
    ],
 
    pug2JsPreprocessor: {
      // Can be pug or jade (defaults to pug_. Used for file extensions and require.
      lib: 'jade',
 
      // strip this from the file path
      stripPrefix: 'public/',
 
      // prepend this to the
      prependPrefix: 'served/',
 
      // By default, Jade/Pug files are added to template cache with '.html' extension.
      // Set this option to change it.
      templateExtension: 'html',
 
      // or define a custom transform function
      cacheIdFromPath: function(filepath) {
        return filepath.replace(/\.jade$/, '.html');
      },
 
      // Support for pug locals to render at compile time
      locals: {
        foo: 'bar'
      },
 
      // set the global cache name for the templates (defaults to templateCache)
      cacheName: 'foo',
 
      // Jade/Pug compiler options. For a list of possible options, consult Jade/Pug documentation.
      pugOptions: {
        doctype: 'xml'
      },
    }
  });
};

For more information on Karma see the homepage.

Package Sidebar

Install

npm i karma-pug2js-preprocessor

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

9.46 kB

Total Files

6

Last publish

Collaborators

  • aclshumway