How to use the precompile function from swig

Find comprehensive JavaScript swig.precompile code examples handpicked from public code repositorys.

3700
3701
3702
3703
3704
3705
3706
3707
3708
3709

/**
 * Pre-compile a source string into a cache-able template function.
 *
 * @example
 * swig.precompile('{{ tacos }}');
 * // => {
 * //      tpl: function (_swig, _locals, _filters, _utils, _fn) { ... },
 * //      tokens: {
 * //        name: undefined,
fork icon0
star icon1
watch icon0

28
29
30
31
32
33
34
35
36
37
this.files.forEach(function(f) {

  var src = f.src;
  var dest = f.dest.replace('.twig', '.js');
  var contents = grunt.file.read(f.src);
  var _tpl = swig.precompile(contents, {}).tpl.toString().replace('anonymous', '');

  _tpl = 'define(function () { return ' + _tpl + '; });';

  // Handle options.
fork icon0
star icon0
watch icon0

+ 2 other calls in file