WearyMonkey / ngtemplate-loader

Include AngularJS templates in the Webpack bundle and preload the template cache.
MIT License
238 stars 78 forks source link

Return templateUrl from require() call #6

Closed srigi closed 9 years ago

srigi commented 9 years ago

Thank you for this loader. It does great job. However it leads to some code duplication. Calling require('some.html') will generate JS code that only adds some.html to $templateCache. It would be great if that require() call would return templateUrl. It can be very clear on directive example:

require('./stateDebugger.html');

module.directive('stateDebugger', function($state) {
  return {
    templateUrl: 'shared/directives/stateDebugger.html',
    link: function() {  /* some code */ }
  };
});

As you can see I have to manually set templateUrl of the directive. It would be great if this would be possible:

templateUrl: require('./stateDebugger.html'),
WearyMonkey commented 9 years ago

Nice idea! I'll look into it.

srigi commented 9 years ago

You are awesome, thank you.