You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

karma-html2js-preprocessor

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-html2js-preprocessor

A Karma plugin. Convert HTML files into JS strings to serve them in a script tag.

1.0.0
Source
npmnpm
Version published
Weekly downloads
25K
-26.39%
Maintainers
2
Weekly downloads
 
Created
Source

karma-html2js-preprocessor Build Status

Preprocessor for converting HTML files into JS strings.

Note: If you are using AngularJS, check out karma-ng-html2js-preprocessor.

Installation

The easiest way is to keep karma-html2js-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-html2js-preprocessor": "~0.1"
  }
}

You can simple do it by:

npm install karma-html2js-preprocessor --save-dev

Configuration

Following code shows the default configuration...

// karma.conf.js
module.exports = function(config) {
  config.set({
    preprocessors: {
      '**/*.html': ['html2js']
    },

    files: [
      '*.js',
      '*.html'
    ]
  });
};

How does it work ?

This preprocessor converts HTML files into JS strings and publishes them in the global window.__html__, so that you can use these for testing DOM operations.

For instance this template.html...

<div>something</div>

... will be served as template.html.js:

window.__html__ = window.__html__ || {};
window.__html__['template.html'] = '<div>something</div>';

See the end2end test for a complete example.

For more information on Karma see the homepage.

Keywords

karma-plugin

FAQs

Package last updated on 03 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts