Tmplz Template API

Tmplz Tags

Core Tags: Slot

A Slot specifies a place where information will be filled in later. Example:

  I'm not sure how to explain this, so I'll let the computer do it: 
  [$Slot Explain] ...Hope that helps.

A Slot always has a name; here, the name is "Explain". An application developer can fill in this slot using the Section.fillin() method, or a Fillin tag in another template can fill it in. A Slot that is not filled in will show up as blank when the template is printed.

Using the same name more than once

A given Slot name can be used more than once in a template. All slots with the same name receive the same value when filled in. For example:

  Dear [$Slot Person],
  
  We are pleased to inform you that you've won a zillion dollars. What do you think 
  of that, [$Slot Person]? We bet you're pretty happy. And remember, [$Slot Person], 
  you can't buy love, but you can buy a Ferrari.
  
  Yours,
  [$Slot Sender]

Here, when "Person" is filled in, it will appear in three different places (the "YourBestFriend" Slot will receive a different value since it has a different name).

Sample Values

Occasionally it's useful to tag a Slot using the following format, which allows for a "sample" value:

  [$Slot MySlot]Here is some sample text, which the Tmplz parser will discard.[$Slot]

Next page: Section