Debian Codegraph @

docs/content/en/methods/page/RenderString.md

raw
1 ---
2 title: RenderString
3 description: Renders markup to HTML.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: template.HTML
9 signatures: ['PAGE.RenderString [OPTIONS] MARKUP']
10 aliases: [/functions/renderstring]
11 ---
12
13 The `RenderString` method on a `Page` object renders markup to HTML.
14
15 ```go-html-template
16 {{ $s := "An *emphasized* word" }}
17 {{ $s | .RenderString }} → An <em>emphasized</em> word
18 ```
19
20 ## Options
21
22 The `RenderString` method on a `Page` object accepts an options map.
23
24 `display`
25 : (`string`) Specify either `inline` or `block`. If `inline`, removes surrounding `p` tags from short snippets. Default is `inline`.
26
27 `markup`
28 : (`string`) Specify a [markup identifier][] for the provided markup. Default is the `markup` front matter value, falling back to the value derived from the page's file extension.
29
30 ## Examples
31
32 Render Markdown content to HTML in block display mode:
33
34 ```go-html-template
35 {{ $opts := dict "display" "block" }}
36 {{ $s | .RenderString $opts }} → <p>An <em>emphasized</em> word</p>
37 ```
38
39 Render [Pandoc] content to HTML in block display mode:
40
41 ```go-html-template
42 {{ $s := "H~2~O" }}
43
44 {{ $opts := dict "markup" "pandoc" "display" "block" }}
45 {{ $s | .RenderString $opts }} → H<sub>2</sub>O
46 ```
47
48 [Pandoc]: /content-management/formats/#pandoc
49 [markup identifier]: /content-management/formats/#classification