How to use the setTag function from swig

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

70
71
72
73
74
75
76
77
78
79
    translation = translation.replace(new RegExp(key, "g"),val);
  });
  return translation;
});

swig.setTag('i18n', function(str, line, parser, types) {
  var handlingTag   = true,  // When we start we're handling the TAG
      endIsSafe     = true,  // We can call end catch all
      handlingSubs  = false, // We are handling substitutions if there is more found after TAG
      accumulatedJS = '';    // This is all of the accumulated javascript
fork icon4
star icon4
watch icon0

3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
*
* For a more in-depth explanation of writing custom tags, see <a href="../extending/#tags">Custom Tags</a>.
*
* @example
* var tacotag = require('./tacotag');
* swig.setTag('tacos', tacotag.parse, tacotag.compile, tacotag.ends, tacotag.blockLevel);
* // => {% tacos %}Make this be tacos.{% endtacos %}
* // => Tacos tacos tacos tacos.
*
* @param  {string} name      Tag name.
fork icon0
star icon1
watch icon0

+ 3 other calls in file

66
67
68
69
70
71
72
73
74
75
  var dateParsed = Date.parse(dateStr);
  var fmt = new cldr.DateTimeFormatter();
  return fmt.format(new Date(dateParsed), {"type": "short"});
});

swig.setTag('currency', function(str, line, parser, types) {
  parser.on(types.NUMBER, parseToken);

  parser.on('*', function (token) {
      throw new Error('!!!Unexpected token: "' + token.match + '" on line ' + line + '.');
fork icon0
star icon0
watch icon0

+ 2 other calls in file