Documentation
¶
Overview ¶
Package interp evaluates Go text/template interpolations in a slide deck's Markdown before the Markdown itself is parsed.
The whole body is executed as one template, so a template can generate slides: a {{range}} that emits "---" separators is a deck generator. The page number and the page total are only known once the deck has been split and paginated, so the page and total functions emit sentinels and Resolve replaces them afterwards. Every template is therefore evaluated exactly once, and a value coming from data is never re-parsed as one.
Code is left alone by default: fenced code blocks and inline code spans are set aside before execution and restored verbatim afterwards, so a slide about Go templates can show {{ .Name }} without escaping it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( PageSentinel = sentinelOpen + "page" + sentinelClose TotalSentinel = sentinelOpen + "total" + sentinelClose )
PageSentinel and TotalSentinel are what the page and total template functions produce.
Functions ¶
func HasSentinel ¶
HasSentinel reports whether s still holds an unresolved sentinel.
Types ¶
type Options ¶
type Options struct {
// Data is the template's dot.
Data map[string]any
// Delims overrides the action delimiters; both empty means "{{" "}}".
Delims [2]string
// Code, when true, interpolates inside code blocks and spans too.
Code bool
// BaseDir resolves the include function's relative paths.
BaseDir string
// Name names the template in error messages.
Name string
// Now is the clock behind the now function; nil means time.Now.
Now func() time.Time
}
Options configures one evaluation.