Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module option #10

Closed
geddski opened this issue Mar 5, 2013 · 6 comments
Closed

module option #10

geddski opened this issue Mar 5, 2013 · 6 comments

Comments

@geddski
Copy link
Contributor

geddski commented Mar 5, 2013

What about this idea: instead of creating app.templates module, just let people specify the name of the module to add templates to:

ngtemplates: {
      app: {
        src: ['app/templates/**/*.html'],
        dest: 'app/templates.js',
        module: 'app'
      }
    },

That way you wouldn't have to specify a dependency:

angular.module('app', []);

The benefit of this is you don't have to run a build before being able to use your app.

@ericclemmons
Copy link
Owner

Hi! I don't know if I understand well enough, but I do know you can change app to whatever you'd like:

ngtemplates: {
  mymodule: {
    src: ['app/templates/**/*.html'],
    dest: 'mymodule/templates.js'
  }
},

This will create mymodule.templates. I can update the README if that helps.

As for the last line about "don't have to run a build", are you saying that you only want to use the templates as the app, without a "parent" module?

Thanks for opening an issue, btw!

@geddski
Copy link
Contributor Author

geddski commented Mar 5, 2013

Right, I get how it currently works. I mean instead of creating a new module named <module-name>.templates, the plugin could add the templates to the module.

So for example, say I have an angular module named app:

angular.module('app', []);

Now I tell the grunt plugin to add all my templates to it (rather than to a separate module):

ngtemplates: {
    app: {
        src: ['app/templates/**/*.html'],
        dest: 'app/templates.js',
        module: 'app'
      }
  }

And now app/templates.js would look like this:

angular.module("app").run(["$templateCache", function($templateCache) {

  $templateCache.put("app/templates/partial1.html",
    "<h1>Users</h1>"...
  );

  $templateCache.put("app/templates/partial2.html",
    "<p>This is the partial for view 2.</p>"...
  );

}]);

Does that make sense? So it adds the templates to my app module, rather than to a separate module that I need to declare as a dependency to my module.

@ericclemmons
Copy link
Owner

Ooh!! I see! I like that a lot better! :D

The one downside is that you'd have to ensure the template is included after the fact (whereas app.templates can be included before or after other module files), but I think that's a trivial downside.

@kwhitley
Copy link

kwhitley commented Mar 5, 2013

I like this!

👍 @GEDDesign

@geddski
Copy link
Contributor Author

geddski commented Mar 5, 2013

Wow that was fast! Rock on dudes. This is a great improvement.

@ericclemmons
Copy link
Owner

Thanks for the PR! Take a look @ some of my other grunt projects & open up issues if you see anything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants