Pop Tags


For manipulating a portion of your template.

If you open up an extension tag in your template, you can access an object that represents the part of the template which is inside of the extension tag by using the enclosed parameter.

Enclosed has two methods:

enclosed.tags() Returns an array of PopTag nodes within the enclosed portion of the template. A node is either an object representing a Pop Tag, or a string representing the portion of a template in-between Pop Tags.
enclosed.render() Returns the enclosed template as a string of html.

Here’s a simple extension method that will repeat the enclosed template:


exports.repeat = function(options, enclosed) {
  var times = options.times ? parseInt(options.times, 10) : 1;
  var result = []
  for (var i=0; i < times; i++) {
  return result.join("");

If used like this:

<pop:example:repeat times="3">

The output would be:

Continue to Scope »