Skip to content

Instantly share code, notes, and snippets.

@geddski
Created October 28, 2014 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geddski/357bc2ba1fe2b4086182 to your computer and use it in GitHub Desktop.
Save geddski/357bc2ba1fe2b4086182 to your computer and use it in GitHub Desktop.
simple Angular template loader for webpack
/**
* Import an Angular template.
* Returns the HTML as a string
* Could be chained with a separate loader if you want to populate Angular's template cache
*/
module.exports = function(source) {
var html = "'" + source.replace(/"/g, '\\\"').replace(/\n/g, '\\') + "'";
return "module.exports = \"" + html + "\"";
};
@geddski
Copy link
Author

geddski commented Oct 28, 2014

Use like so:

...
template: require('template!./path/to/template.html')
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment