ng-html-to-js

converts angular templates into JavaScript call to $templateCache.put(path, content), avoiding roundtrips to the server

Usage no npm install needed!

<script type="module">
  import ngHtmlToJs from 'https://cdn.skypack.dev/ng-html-to-js';
</script>

README

WAT?

ng-html-to-js converts angular templates into JavaScript call to $templateCache.put(path, content),
avoiding roundtrips to the server.

I wanted an alternative for grunt-angular-templates without depending on grunt. Seemed feasible...

TODO

  • Minify html without breaking changes

Usage (cli)

ng-html-to-js -s src -d bundle.js
  • -s source dir to look for templates (default is src)
  • -d destination script path (overrides any content, default to bundle.js)
  • -f file regular expression (defaults to /\.html$/)
  • -m function returning the modName, given param p which is the file path (default is return "app")
  • -t template root path (defaults to /)
  • -v verbose (boolean, default is false)

Usage (programmatic)

var ngHtmlToJs = require('ng-html-to-js');

// the values below are the defaults. if they're fine you can omit them.

ngHtmlToJs({
  srcDir: 'src',
  dstFile: 'bundle.js',
  fileRegex: /\.html$/),
  getModName: function(p) { return 'app'; },
  tplRootPath: '/',
  verbose: false,
  cb: function(err) {
    if (err) {
      console.error(err);
    }
  }
});