Pop Tags


The context for your new tag.

The scope argument can be used to access variables within the scope of a Pop Tag. A tag is always in a context. For example, a tag at the root of a template, like <pop:content>, will have all the tags we’ve learned about so far in it’s scope (entries, sections, content, categories, etc.). The scope of a nested tag will depend on the parent tag.

scope.lookup("example") Traverses up the heirarchcy of tags in the template until it finds the "example" variable in the scope of one of the parents.

Here’s an example of using the scope from an extension method:


exports.person = {
  first_name: "Bender",
  last_name: "Rodriguez"

exports.full_name = function(options, enclosed, scope) {
  return scope.first_name + " " + scope.last_name;

This template:

  <h2><pop:example:full_name /></h2>

Outputs: <h2>Bender Rodriguez</h2>.

A scope lookup does a direct lookup in the current scope of the tag and doesn't traverse up the scope. Call lookup on the scope to make it climb the hierachy of tags. The above full_name method could be rewritten like this:


exports.full_name = function(options, enclosed, scope) {
  return scope.lookup("first_name") + " " + scope.lookup("last_name");
Continue to Routes »