ng-templatecache-convert

1.0.4 • Public • Published

ng-templatecache-convert

CLI tool for converting a list of html files to a single JavaScript file that loads the html content into the Angular $templateCache

Usage

ngtemplateconvert <angularModuleName> <inputGlobPatterns>... <outputFile>

Optional arguments:

  • cwd - Sets the current working directory for the input glob patterns

Example

Imagine you have a project structured like so:

|
|--- html
  |
  |--- example.html
  |
  |--- test
    |
    |--- test.html
    |
    |--- test2.html
  

The html files have the following contents:

<!-- example.html -->
<p>Example</p>
<!-- test.html -->
<p>Test</p>
<!-- test2.html -->
<p>Test 2</p>

Running the following shell script will produce ngTemplates.js using all the html files in the html directory, other than test2.html. The angular module will be "ngTest".

ngtemplateconvert ngTest -cwd="html" '*.html' '!test/test2.html' ngTemplates.js 

The contents of ngTemplates.js looks like this:

(function(){
    angular.module('ngTest').run(loadTemplates);
    loadTemplates.$inject=['$templateCache'];
    function loadTemplates($templateCache){
        $templateCache.put('example.html','<p>Example</p>');
        $templateCache.put('test/test.html','<p>Test</p>');
    }
})();

Package Sidebar

Install

npm i ng-templatecache-convert

Weekly Downloads

0

Version

1.0.4

License

MIT

Last publish

Collaborators

  • rydahhh