FormattedText
FormattedText is a data container that can hold text with formatting options (among others bold, italics, underline, breaks or even Word-specific formatting).
Regardless of the context, FormattedText is technically HTML:
<p>Erstellt mit: <b>primedocs</b>!</p>
Created with: primedocs!
FormattedText is ideal for mapping simple formatting options that can be used in Word, PowerPoint or Outlook templates.
Product-specific formatting options can also be stored in FormattedText, so that, for example, a paragraph in Word can be equipped with a style.
Syntax
FormattedText occurs in primedocs as...
- a Field type, so it can be generated as code, whereby FormattedText can be fetched as a Snippet or global translation.
- the type of a global translation
- a Snippet type.
HTML Elements
The following lists show all possible HTML elements and their attributes that can be used in the templates.
Word template types
Elements:
<p>Paragraph</p>
<span>Span</span>
<sup>hochgestellt</sup>
<sub>tiefgestellt</sub>
<u>unterstrichen</u>
<i>kursiv</i>
<em>kursiv</em>
<b>fett</b>
<strong>fett</strong>
<br />
<custom-tab />
Attributes on span and p:
"data-office-font"
"data-office-font-size"
"data-office-color-hex"
"data-office-color-theme-name"
"data-word-style-id"
"data-word-space-after"
"data-word-space-before"
"data-word-indentation"
"data-word-alignment" (Center, Right, Left)
Attribute on br:
"data-word-break-type" (Page)
PowerPoint template types
Elements:
<p>Paragraph</p>
<span>Span</span>
<sup>superscript</sup>
<sub>subscript</sub>
<ul><li>list</li></ul>
<ol><li>list</li></ol>
<u>underline</u>
<i>italic</i>
<em>italic</em>
<b>bold</b>
<strong>bold</strong>
<br />
Attributes on span and p:
"data-office-font"
"data-office-font-size"
"data-office-color-hex"
"data-office-color-theme-name"
"data-powerpoint-alignment" (Center, Right, Left)
Dynamic Attributes
Some native HTML attributes can be populated with values from Fields.
Example:
<a href="{{url}}">Link</a>
Supported attributes:
alt
aria-label
class
href
id
name
src
title
value
Any attribute not listed here cannot be set dynamically — this applies in particular to all data- attributes. This restriction ensures the validatability of the templates.
Outlook (new) — template types
This refers to the web-capable Outlook client (Outlook (new)). It uses HTML as the "description" for e-mails and signatures, so FormattedText data can be used directly here. In addition, all HTML elements and attributes permitted by Outlook can be used.
Outlook (new) ignores certain CSS properties such as white-space: pre-wrap, so line breaks and spaces are not rendered as in standard browsers. To achieve the desired layout, inserting <br> elements is necessary.
FormattedText as a Field
If a FormattedText is to be embedded into one (or more) template(s), this can be defined in a Field of the FormattedText type.
Paragraph behaviour — depending on the occurrence of paragraphs (<p>):
- If at least one of the elements is a paragraph, all non-paragraph elements are each placed in a separate paragraph.
- If none of the elements is a paragraph, all elements are concatenated directly without additional paragraph breaks.
This behaviour is intentional and applies to all FormattedText regardless of its origin or use.
A global translation of the FormattedText type can be output in Fields via the translations API:
$.translations.getFormattedText("FormattedTexts.EnclosuresTitle")
Existing Snippets of the FormattedText type can also be accessed via the snippets API:
$.snippets.getFormattedText("FormattedTexts.SimpleSnippet")
FormattedText as a Global Translation
A FormattedText can be saved as a global translation in the Global Translations. The advantage is that no Snippet has to be created; instead, the text can be created directly in its technical format, HTML.
FormattedText as a Snippet
A FormattedText can also be saved as a Snippet of the FormattedText type under the template Snippets. However, Snippets of this type are only used for template construction or templating and are therefore not used by end users.
FormattedText Snippets cannot store tables, images or other complex content. Snippets of the WordContent type are suitable for this purpose, however.
FormattedText Snippets are less flexible than global translations or the definition in the Fields, but there is an automatic converter: if you create a text in Word, you can save the Snippet as FormattedText via the Snippet sidebar.
Placeholders, Loops and Conditions
Named parameters can be used to create placeholders in global translations that later fill paragraphs or loops with dynamic data via the Fields.
Here primedocs uses the HTML template engine "Handlebars.js". You can find the documentation here: Expressions | Handlebars.