yaru22 / ng-html2js

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

Strip prefix #9

Closed mikeymc closed 9 years ago

mikeymc commented 9 years ago

In response to the previous response to #8 with this work, please try this one.

This feature adds the ability to strip an arbitrary prefix from the input file name.

In our last two projects, we found it difficult to figure out how to strip a prefix from a file name to be placed into the key of the $templateCache.put(). We wished there was a way to simply strip some arbitrary prefix, but that feature did not exist. We saw the -b/--basedir option, but we could not figure out how to use it properly. As a result, we found ourselves having to change directories to the level where the relative path to the file would wind up being what we wanted to see in the key of the $templateCache.put(). This was a drag. It seems others have also had similar issues with the --basedir option. So, we added the ability to strip an arbitrary prefix.

The behavior of the feature is specified in the tests that accompany this pull request.

In short, to strip an arbitrary prefix, run the following:

./path/to/ng-html2js path/to/file.tmpl -s path/to/

this will yield:

$templateCache.put('file.tmpl', 'the-rest-of-the-magic-goodness')