yaru22 / ng-html2js

Standalone script to turn Angular template into js and put it in a module.
32 stars 19 forks source link

add support for multiple files or glob pattern #14

Open mikedon opened 8 years ago

mikedon commented 8 years ago

From what I can tell this only support one file. I could probably invoke the module multiple times but each time I would get the ngModule lookup code. In my projects I have many html files that live close to their respective controllers.

I'll submit a PR if you think this functionality should be added.

bensontrent commented 8 years ago

I'm in favor of this change; I am using a npm script with onchange to watch a folder and the file change will trigger a build with ng-html-js. It doesn't work until the file is changed,, and I don't have the output combined to one file yet; but its a hacky-start to allow ng-html2js to work with file globs.

How to use a glob pattern to convert html templates with ng-html2js & onchange.

On the console npm install onchange -g

In package.json:

{
...
 "scripts": {
...
  "watch:html": "onchange \"**/*.html\" -- ng-html2js \"{{changed}}\" \"{{changed}}\".js -m MyModuleName --module-var MyModuleVar"
  },
...
}

On the console: npm run watch:html

(nothing will happen)

For the magic: Make a change to an html file and a companion js file will be generated as long as the watch:html is running.

There's probably a method that can take the combined output and process the directory without the files being changed, but this is what I came up with in 10 mins.