Templates are the heart of reBB's functionality, transforming user input into beautifully formatted output. This guide will help you master the template system and create precisely formatted content.
A template is essentially a blueprint for your output. It consists of:
When a user fills out your form, reBB processes the template, replacing each wildcard with the corresponding user input to generate the final formatted output.
Where to Find the Template Editor
After adding components to your form, scroll down to find:
Creating a Simple Template
Let's start with a basic example. If your form has fields for a character's name, race, and class, your template might look like:
[b]Character Sheet[/b]
[b]Name:[/b] {characterName}
[b]Race:[/b] {characterRace}
[b]Class:[/b] {characterClass}
When a user completes this form, the output might look like:
[b]Character Sheet[/b]
[b]Name:[/b] Elyndra
[b]Race:[/b] Elf
[b]Class:[/b] Ranger
Each form component generates a unique wildcard based on its Key:
{key}
in your templateFor example, if you have a text field with the key "productName_UNIQUEKEY", you must use the wildcard {UNIQUEKEY}
in your template (not {ProductName}
or {product_name}
).
Formatting Your Output
You can add any static formatting around your wildcards:
BBCode Example:
[center][size=18][color=#336699]{postTitle}[/color][/size][/center]
[b]Posted by:[/b] {authorName}
[b]Date:[/b] {postDate}
[hr]
{postContent}
[hr]
[size=10]Tags: {postTags}[/size]
HTML Example:
<h1>{articleTitle}</h1>
<p class="byline">By {authorName} | {publicationDate}</p>
<div class="content">
{articleContent}
</div>
<div class="tags">
Tags: {articleTags}
</div>
While reBB doesn't have direct if/then syntax in templates, you can use JavaScript in the Standard Editor to achieve conditional output by manipulating the values that go into wildcards.
For example, you could use a calculated value for a hidden field that combines other fields conditionally:
// In a calculated value field with key "statusLine"
if (data.isActive) {
value = "Status: Active since " + data.startDate;
} else {
value = "Status: Inactive";
}
Then in your template, use {statusLine}
to display the appropriate message.
Dynamic Title Field
reBB offers a separate template field specifically for titles:
Example title template:
[Character Sheet] {characterName} the {characterRace} {characterClass}
Which might generate:
[Character Sheet] Elyndra the Elf Ranger
External Link Button
The External Link Button provides users with a direct way to use their generated content:
This is particularly useful for forum templates, where you can link directly to your forum's posting page.
Datagrids (available in the Standard Editor) require special wildcards in your template.
Dataset Wildcards
For a datagrid with the key "inventory", you'll have these special wildcards:
{@START_inventory@}
- Marks the beginning of repeatable content{@END_inventory@}
- Marks the end of repeatable contentBetween these markers, you place the template for a single row, using the component keys from within the datagrid.
Datagrid Template Examples
Example 1: Simple List
[b]Inventory:[/b]
[list]
{@START_inventory@}[*]{item} (Quantity: {quantity}){@END_inventory@}
[/list]
This would generate:
[b]Inventory:[/b]
[list]
[*]Healing Potion (Quantity: 5)
[*]Rope (Quantity: 1)
[*]Torch (Quantity: 3)
[/list]
Example 2: Table
[table]
[tr][th]Item[/th][th]Quantity[/th][th]Notes[/th][/tr]
{@START_inventory@}[tr][td]{item}[/td][td]{quantity}[/td][td]{notes}[/td][/tr]{@END_inventory@}
[/table]
Important Datagrid Notes
Common Issues and Solutions
Wildcard not being replaced
Formatting issues with line breaks
<pre>
tags in HTML templatesDatagrid content not repeating
{@START_key@}
and {@END_key@}
markersMissing or unexpected output
With these techniques and best practices, you can create sophisticated templates that transform simple form input into perfectly formatted, consistent output every time.