Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-angular-templates

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-angular-templates

Grunt build task to concatenate & register your AngularJS templates in the $templateCache

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
increased by12.32%
Maintainers
1
Weekly downloads
 
Created
Source

grunt-angular-templates Build Status

Grunt build task to concatenate & register your AngularJS templates in the $templateCache

NOTE:

  • Use 0.1.x for Grunt 0.3.x.
  • Use 0.2.x or 0.3.x for Grunt 0.4.x.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-angular-templates

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-angular-templates');

Documentation

This plugin provides the grunt task ngtemplates, which will allow you to compile your HTML templates into a single JS file, which preloads $templateCache to prevent round-trips to the server.

Update Grunt

// grunt.js
grunt.initConfig({
  ngtemplates:  {
    myapp:      {
      options:  { base: 'src/views' },
      src:      [ 'src/views/**.html' ],
      dest:     'dist/templates.js'
    }
  }
});

You should name your sub-target (e.g. myapp) after the name of the module the templates will be added to.

This will generate the following at dist/templates.js:

angular.module('myapp').run(['$templateCache', function($templateCache) {
  ...
}]);

Include Compiled Templates

This can either be done via HTML:

<script src="dist/templates.js"></script>

or via your Gruntfile:

concat: {
  myapp: {
    src: [
      'src/js/**/*.js',       // MyApp module first
      '<%= ngtemplates.myapp.dest %>' // Generated templates
    ],
    dest: 'dist/js/app.js'
  }
}

Changelog

v0.3.0

  • BC break - Templates are added to an existing module (e.g. myapp) rather than being their own myapp.templates module to be manually included, thanks to @geddesign. (#10)

v0.2.2

  • Fixes

    • Escape backslashes, thanks to @dallonf. (#9)

v0.2.1

  • Remove ./bin/grunt-angular-templates. No need for it!

v0.2.0

  • Update to Grunt 0.4, thanks to @jgrund. (#5)

v0.1.3

  • Fixes

    • Convert \\ to / in template IDs (for on win32 systems) (#3)

v0.1.2

  • Added NPM keywords

v0.1.1

v0.1.0

  • Released to NPM

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

License

Copyright (c) 2013 Eric Clemmons Licensed under the MIT license.

Keywords

FAQs

Package last updated on 05 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc