FormattedText

FormattedText


Purpose

FormattedText is a data container that can contain text with formatting options (e.g. bold, italics, underlines, breaks or even Word-specific formatting).

Regardless of the context, FormattedText is technically HTML:

<p>Created with: <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...

  • Field type, thus can be generated as code, whereby FormattedText can be fetched as a text module or global translation.

  • Type of a global translation

  • Text module type.

HTML-Elements

The following lists show all possible HTML elements and their attributes that can be used in the templates (either as a text module, as a field type, etc.).

Word-Template Types

Elements:

<p>Paragraph</p> <span>Span</span> <sup>superscript</sup> <sub>subscript</sub> <u>underline</u> <i>italic</i> <em>italic</em> <b>bold</b> <strong>bold</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)

Attributes 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)

Outlook (new) - Template Types

This refers to the web-enabled Outlook client.

The web-enabled Outlook client (Outlook (new)) uses HTML as a “description” for emails and signatures. Formatted text data can therefore be used directly here. In addition, all supported HTML elements and attributes that Outlook allows can be used.

FormattedText as a Field

If you want to include a FormattedText in one (or more) template(s), this can be defined in a field of the FormattedText type. The field can then be used to output global FormattedText translations, text modules of the FormattedText type, fixed texts or other fields.

A global translation of the FormattedText type can be output in Fields via the translations API. Similarly, existing text modules of the formatted text type can also be accessed via the snippets API. The formattedText API offers further options.

Find out more about using FormattedText fields in the Layouter manual: Word: Dive into Fields

FormattedText as a Globale Translation

FormattedText can be saved as a global translation in the Global translations. The advantage of this is that you do not have to create a text module but can create the text directly in its technical format, HTML, and can also use the “Handlebars.js” syntax very easily.

Global FormattedText translations are output via a FormattedText field via the translations API when creating documents.

FormattedText as a text module

A FormattedText can also be saved as a text module of the Formatted Text type under the template text modules. However, text modules of this type are only used for template construction or templating and are therefore not used by end users.

FormattedText text modules cannot save tables, images or other complex content. However, text modules of the WordContent type are suitable for this purpose.

There is also no way to map the Handlebars.js syntax for control structures (conditions) or loops. Global FormattedText translations are used for this purpose.

FormattedText text modules are output via a FormattedText field using the snippets API when documents are created.

HINT

FormattedText text modules 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 text module as formatted text via the text module sidebar and continue to use the generated HTML content (e.g. for a global FormattedText translation).

Placeholders, loops and conditions

Named parameters can be used to create placeholders in global translations that later fill paragraphs (<p></p>) 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 (handlebarsjs.com).

Loops and conditions can also be implemented in the fields directly via JavaScript. See our Layouter manual: JavaScript in Fields.

 

PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland