TinyMCE merge tags: preserve template fields until the application fills them

TinyMCE's premium Merge Tags plugin lets authors insert named fields such as {{Booking.StartTime}} as protected tokens. Configure the mergetags plugin, its toolbar control, and a nonempty mergetags_list. The editor supplies token insertion and recognition; your application must supply the actual recipient data and final merge. Merge Tags documentation

An original room-booking email needs the attendee's name, room, and start time. The template author should see readable choices without accidentally editing half a field name. The recipient should receive “Room Cedar at 2:30 p.m.” only after the booking application has resolved those values.

Give authors fields with stable values and readable labels

In an existing TinyMCE installation with access to the premium plugin, this configuration supplies a small catalog:

tinymce.init({
  selector: '#booking-template',
  plugins: 'mergetags',
  toolbar: 'undo redo | bold italic | mergetags',
  mergetags_list: [
    { value: 'Attendee.Name', title: 'Attendee name' },
    {
      title: 'Booking',
      menu: [
        { value: 'Booking.Room', title: 'Room name' },
        { value: 'Booking.StartTime', title: 'Start time' }
      ]
    }
  ]
});

The page must already load TinyMCE and provide the #booking-template element. Premium access and delivery must match the installation; adding a plugin name does not grant entitlement. Check the installed release's documentation when integrating it.

value identifies the field inserted into the template. title is the author's menu label. Keep the field identity stable when changing a label from “Room name” to “Meeting room.” Otherwise, stored templates can retain values that the server no longer knows how to resolve.

Match the delimiters and the allowed field catalog

The default delimiters are {{ and }}. Typing the prefix triggers the autocompleter, and subsequent characters filter the configured list. Authors can also choose a field from the toolbar menu. If the list is absent or empty, the toolbar/menu entries are hidden and autosuggestions are disabled.

For the booking example, the editable message might read:

Hello {{Attendee.Name}},
Your room is {{Booking.Room}}.
Your booking starts at {{Booking.StartTime}}.

If a server-side template system requires different delimiters, configure mergetags_prefix and mergetags_suffix to match it deliberately. Test the exact spelling and case of each field. A token-like string is not proof that it matches the configured catalog or the server's field identifier.

Recognized merge tags are noneditable tokens, but authors can apply inline formatting and replace a selected tag with another available tag. Matching pasted text can also be recognized. That behavior helps template editing; it does not authorize a field or validate its source value.

Keep template storage separate from recipient rendering

Save the editor's template through the application's supported content route. The TinyMCE content guide covers obtaining that value and distinguishing it from backing form data. Preserve tokens in this template copy so the same template can serve another booking.

Resolve fields in a separate rendering step with the application's actual template engine. Allow only approved field names, check access to the booking record, and apply the engine's escaping rules for the output context. An attendee name must not become executable markup because it was inserted into an HTML email. A plain string replacement loop is insufficient for a production renderer that handles HTML, attributes, and missing values.

For a developer-created fixture, define attendee “Robin,” room “Cedar,” and start time “2:30 p.m.” The resulting message should contain those values and no unresolved booking tokens. These are illustrative inputs, not a real booking or a verified mail-delivery result.

Choose a missing-value policy before sending. For this message, a missing room should block sending and identify the unresolved field. Silently turning it into an empty string would produce a plausible-looking email that omits the location.

Check the authored token and the rendered email separately

Insert the room token through the catalog, change its formatting, save the template, and reopen it in the same supported integration. Confirm that authors still see a recognized token. Then render a copy with the fixture data and read the final email in the actual email preview or sending system.

The protected-region guide addresses fixed document text, while content templates insert larger reusable structures. Merge tags serve a different job: one stored template can refer to values supplied for each recipient.

Finish with two retained artifacts: the reusable template still contains the three fields, and the booking-specific preview contains Robin's actual room and start time. A token that looks protected in the editor is only the first half of that check.

Keep reading