javoire / browserify-ng-html2js

Browserify transform to compile html templates into angular template modules
MIT License
27 stars 17 forks source link

Generated module should export the name of the angular module instead of filename #39

Open javoire opened 8 years ago

javoire commented 8 years ago

Currently it's exporting the filename:

var src = ngHtml2Js(fileName, content, opts.module, 'ngModule') + '\nmodule.exports = "' + fileName + '"';

Exporting the name of the module allows you to do this:

angular.module('myApp', [
  require('./templates/home.html')
])

// or

var homeTemplate = require('./templates/home.html')
angular.module('myApp', [
  homeTemplate
])

You can still do this in most cases, but that's just because the module name and the filename usually is the same. It's not the case in the situation though: https://github.com/javoire/browserify-ng-html2js/blob/master/test/fixtures/output.js