Documentation ¶
Index ¶
- func NewLinkHelper(formatter core.LinkFormatter, logger util.Logger) interface{}
- func NewSlugHelper(lang string, logger util.Logger) interface{}
- func NewStyleHelper(styler core.Styler, logger util.Logger) interface{}
- func RegisterConcat()
- func RegisterDate(logger util.Logger)
- func RegisterJSON(logger util.Logger)
- func RegisterJoin()
- func RegisterList(supportsUTF8 bool)
- func RegisterPrepend(logger util.Logger)
- func RegisterShell(logger util.Logger)
- func RegisterSubstring()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLinkHelper ¶
func NewLinkHelper(formatter core.LinkFormatter, logger util.Logger) interface{}
NewLinkHelper creates a new template helper to generate an internal link using a LinkFormatter.
{{format-link "path/to/note.md" "An interesting subject"}} -> (depends on the LinkFormatter)
[[path/to/note]] [An interesting subject](path/to/note)
func NewSlugHelper ¶
NewSlugHelper creates a new template helper to slugify text.
{{slug "This will be slugified!"}} -> this-will-be-slugified {{#slug}}This will be slugified!{{/slug}} -> this-will-be-slugified
func NewStyleHelper ¶
NewStyleHelper creates a new template helper which stylizes the text input according to predefined styling rules.
{{style "date" created}} {{#style "red"}}Hello, world{{/style}}
func RegisterConcat ¶
func RegisterConcat()
RegisterConcat registers a {{concat}} template helper which concatenates two strings.
{{concat '> ' 'A quote'}} -> "> A quote"
func RegisterDate ¶
RegisterDate registers the {{date}} template helpers which format a given date.
It supports various styles: short, medium, long, full, year, time, timestamp, timestamp-unix or a custom strftime format.
{{date now}} -> 2009-11-17 {{date now "medium"}} -> Nov 17, 2009 {{date now "%Y-%m"}} -> 2009-11
func RegisterJSON ¶ added in v0.6.0
RegisterJSON registers a {{json}} template helper which serializes its parameter to a JSON value.
func RegisterJoin ¶
func RegisterJoin()
RegisterJoin registers a {{join}} template helper which concatenates list items with the given separator.
{{join list ', '}} -> item1, item2, item3
func RegisterList ¶
func RegisterList(supportsUTF8 bool)
RegisterList registers a {{list}} template helper which formats a slice of strings into a bulleted list.
func RegisterPrepend ¶
RegisterPrepend registers a {{prepend}} template helper which prepend a given string at the beginning of each line.
{{prepend '> ' 'A quote'}} -> "> A quote" {{#prepend '> '}}A quote{{/prepend}} -> "> A quote"
A quote on several lines {{/prepend}}
> A quote on > several lines
func RegisterShell ¶
RegisterShell registers the {{sh}} template helper, which runs shell commands.
{{#sh "tr '[a-z]' '[A-Z]'"}}Hello, world!{{/sh}} -> HELLO, WORLD! {{sh "echo 'Hello, world!'"}} -> Hello, world!
func RegisterSubstring ¶ added in v0.7.0
func RegisterSubstring()
RegisterSubstring registers a {{substring}} template helper which extracts a substring given a starting index and a length.
{{substring 'A full quote' 2 4}} -> "full" {{substring 'A full quote' -5 5}} -> "quote"
Types ¶
This section is empty.