reBB Documentation

Understanding Templates and Wildcards

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.

What is a Template?

A template is essentially a blueprint for your output. It consists of:

  • Static text: The unchanged formatting and text that appears in every output
  • Wildcards: Special placeholders that get replaced with user input

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.

Template Basics

Where to Find the Template Editor

After adding components to your form, scroll down to find:

  1. The Available Wildcards section, which lists all wildcards from your form
  2. The Form Template text area, where you'll create your template

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

Understanding Wildcards

Each form component generates a unique wildcard based on its Key:

  • Wildcards appear as {key} in your template
  • Keys are automatically generated but can be customized
  • Keys are case-sensitive and must match exactly

For 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}).

Advanced Templating Techniques

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>

Conditional Text

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.

Special Template Features

Dynamic Title Field

reBB offers a separate template field specifically for titles:

  1. Enable the Dynamic Title Field toggle in Additional Form Options
  2. Enter a template with wildcards in the title field
  3. This generates a separate output field perfect for thread titles or document headings

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:

  1. Enable the External Link Button toggle
  2. Enter the URL where users should post their content
  3. A "Post Content" button will appear next to the copy button in the output

This is particularly useful for forum templates, where you can link directly to your forum's posting page.

Working with Datagrids

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 content

Between 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

  • Dataset wildcards are highlighted in red in the wildcards section
  • You must use both the START and END wildcards in your template
  • Be careful with line breaks and formatting between the markers
  • Everything between the markers repeats for each row the user adds

Template Troubleshooting

Common Issues and Solutions

  1. Wildcard not being replaced

    • Ensure the key in your template exactly matches the component key
    • Check for typos and correct case
    • Verify the field has a value entered
  2. Formatting issues with line breaks

    • Check how your target platform handles line breaks
    • Add explicit break tags if needed
    • Consider using <pre> tags in HTML templates
  3. Datagrid content not repeating

    • Ensure you've used both {@START_key@} and {@END_key@} markers
    • Check that the datagrid key matches your wildcards
    • Make sure users have added at least one row of data
  4. Missing or unexpected output

    • Preview your form with test data before saving
    • Use the browser's inspection tools to see the actual content
    • Check if conditional logic is hiding components

With these techniques and best practices, you can create sophisticated templates that transform simple form input into perfectly formatted, consistent output every time.