jst.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Precompiles Underscore templates to a `.jst` file.
  3. *
  4. * ---------------------------------------------------------------
  5. *
  6. * (i.e. basically it takes HTML files and turns them into tiny little
  7. * javascript functions that you pass data to and return HTML. This can
  8. * speed up template rendering on the client, and reduce bandwidth usage.)
  9. *
  10. * For usage docs see:
  11. * https://github.com/gruntjs/grunt-contrib-jst
  12. *
  13. */
  14. module.exports = function(grunt) {
  15. var templateFilesToInject = [
  16. 'templates/**/*.html'
  17. ];
  18. grunt.config.set('jst', {
  19. dev: {
  20. // To use other sorts of templates, specify a regexp like the example below:
  21. // options: {
  22. // templateSettings: {
  23. // interpolate: /\{\{(.+?)\}\}/g
  24. // }
  25. // },
  26. // Note that the interpolate setting above is simply an example of overwriting lodash's
  27. // default interpolation. If you want to parse templates with the default _.template behavior
  28. // (i.e. using <div></div>), there's no need to overwrite `templateSettings.interpolate`.
  29. files: {
  30. // e.g.
  31. // 'relative/path/from/gruntfile/to/compiled/template/destination' : ['relative/path/to/sourcefiles/**/*.html']
  32. '.tmp/public/jst.js': require('../pipeline').templateFilesToInject
  33. }
  34. }
  35. });
  36. grunt.loadNpmTasks('grunt-contrib-jst');
  37. };