dougmoscrop / angularjs-templates-brunch

Compile templates in to an AngularJS module as a Brunch plugin
MIT License
5 stars 8 forks source link

[feature] Export template path for convinence #5

Open ghost opened 8 years ago

ghost commented 8 years ago

When i use brunch with your plugin i end up with code like this:

// This is needed to actually add template to angular's cache.
// Also path string must be WITHOUT extension
require('directives/comments-box/comments-box.template');

angular.module('beagle')
  .directive('commentsBox', function($templateCache, OAuth) {
    return {
      // here we NEED to add extension. And this is just duplicate of previous path
      templateUrl: 'directives/comments-box/comments-box.template.html',
      restrict: 'E',
      scope: true,
      link: function(scope, element, attrs) {
      },
    };
  });

which is horrible. templateUrl: require('template/path/with.ext') will be very nice.

ghost commented 8 years ago

Maybe there is some workaround, which will allow use of templates without require? Please don't suggest just to turn commonJS wrappers off for whole project. This is not a solution.

dougmoscrop commented 8 years ago

It's been a while since I used this. The way I remember doing so is I had my templates in a joinTo, using some regex, so I did not have the repetition that you describe. Is that what you mean by not using commonJS?

ghost commented 8 years ago

Brunch have an ability to turn off CommonJS wrappers so all of your code wil be concatenated as is. Of course in this case will appear issues with concatenation order so i really want to use default modular approach. The thing with your plugin is that every template become CommonJS module and you need to explicitly require them. Not a big deal but for now it is just inconvinent.

ghost commented 8 years ago

I think that all we need is just loader for HTML, because then we can just template: require('./template.html')