Plain Text

In Haml templates, plain text can be written directly as template content. EGO templates use normal HTML text. Slim needs one extra marker for a standalone line of text; see Slim text blocks below.

This is plain text

renders as:

This is plain text

Plain text can also follow a tag, in both Haml and Slim.

%p This is plain text
p This is plain text

renders as:

<p>This is plain text</p>

Slim text blocks

Slim tag names are bare words, so a standalone line starting with a letter is parsed as a tag, not as text. To write a standalone line of plain text in Slim, prefix it with a pipe | character.

p
  | This is plain text

renders as:

<p>
This is plain text
</p>

Leaving off the | changes the meaning instead of raising an error. This is plain text on its own line would be parsed as a <This> tag containing the text is plain text. Always mark standalone text lines with | in Slim, even when they read like ordinary sentences.

Text written after a tag on the same line, like p This is plain text above, does not need the | marker; the ambiguity only exists for a line that starts with the text itself.

HTML

In Haml and Slim templates, HTML mixed into plain text is treated as text and rendered as is.

%p
  This is plain text
  <strong>and HTML is too</strong>
p
  | This is plain text
  | <strong>and HTML is too</strong>

renders as:

<p>
  This is plain text <strong>and HTML is too</strong>
</p>

You’ve put thought into what you’ve written into the text. GoHT will respect that and render it as is.

Escaping

Haml only. Because Haml uses prefixes to indicate the type of content, you may need to escape those prefixes from time to time. This is done by using the backslash \ character.

%p
  This element was created with a
  \%p tag followed by some plain text

renders as:

<p>
  This element was created with a %p tag followed by some plain text
</p>

The backslash \ character is used to escape the % character, and any other character that GoHT recognizes as a prefix. You will only need to use the backslash \ character at the beginning of a line.

GoHT will not try to parse the content looking for prefixes in the middle of your content.

%p
  GoHT won't treat %p as a tag in the middle of a line

renders as:

<p>
  GoHT won't treat %p as a tag in the middle of a line
</p>

Slim doesn’t have or need a backslash escape: since every standalone text line already requires the | marker described above, there’s no ambiguous prefix character to escape.