Interpolation

You can include Go variables and expressions in your plain text content. This is called interpolation. Interpolation is accomplished by using the #{} syntax.

%h1 Hello, #{name}!

Assuming name has the value of “World”, this will render as:

<h1>Hello, World!</h1>

Values and the results of expressions that are added this way will be escaped. So, while the plain text content around it will not be escaped, the interpolated content will be.

For example:

- name := "<strong>World</strong>"
Hello, #{name}!

renders as:

Hello, &lt;strong&gt;World&lt;/strong&gt;!

Unescaped Interpolation

If you want to include the content without escaping it, you can use the ! character before the plain text content.

- name := "<strong>World</strong>"
! Hello, #{name}!

renders as:

Hello, <strong>World</strong>!

The unescape character ! will only affect the interpolated content and will not alter the plain text content because it is already considered to be unescaped.

The unescape character ! can be used for plain text that follows a tag as well.

- name := "<strong>World</strong>"
%p! Hello, #{name}!

renders as:

<p>Hello, <strong>World</strong>!</p>