Documentation
¶
Overview ¶
Package tmpl provides various functions for use in Go templates.
Example (Add) ¶
fmt.Println(add(2, 3))
Output: 5
Example (Div) ¶
fmt.Println(div(6, 3))
Output: 2
Example (LowercaseFirstCharacter) ¶
fmt.Println(lowercaseFirstCharacter("Hello")) fmt.Println(lowercaseFirstCharacter("hello")) fmt.Println(lowercaseFirstCharacter(""))
Output: hello hello
Example (MdBold) ¶
fmt.Println(mdBold("Hello, World!"))
Output: **Hello, World!**
Example (MdCode) ¶
fmt.Println(mdCode("fmt.Println(\"Hello, World!\")"))
Output: `fmt.Println("Hello, World!")`
Example (MdEmoji) ¶
fmt.Println(mdEmoji("smile"))
Output: :smile:
Example (MdFootnote) ¶
fmt.Println(mdFootnote(1, "This is a footnote."))
Output: [^1]: This is a footnote.
Example (MdFootnoteRef) ¶
fmt.Println(mdFootnoteRef(1))
Output: [^1]
Example (MdH1) ¶
fmt.Println(mdH1("Hello, World!"))
Output: # Hello, World!
Example (MdH2) ¶
fmt.Println(mdH2("Hello, World!"))
Output: ## Hello, World!
Example (MdH3) ¶
fmt.Println(mdH3("Hello, World!"))
Output: ### Hello, World!
Example (MdH4) ¶
fmt.Println(mdH4("Hello, World!"))
Output: #### Hello, World!
Example (MdH5) ¶
fmt.Println(mdH5("Hello, World!"))
Output: ##### Hello, World!
Example (MdH6) ¶
fmt.Println(mdH6("Hello, World!"))
Output: ###### Hello, World!
Example (MdHR) ¶
fmt.Println(mdHR())
Output: ---
Example (MdHeading) ¶
fmt.Println(mdHeading("Hello, World!", 1)) fmt.Println(mdHeading("Hello, World!", 2))
Output: # Hello, World! ## Hello, World!
Example (MdImage) ¶
fmt.Println(mdImage("Gopher", "https://golang.org/doc/gopher/frontpage.png"))
Output: 
Example (MdItalic) ¶
fmt.Println(mdItalic("Hello, World!"))
Output: *Hello, World!*
Example (MdLink) ¶
fmt.Println(mdLink("Google", "https://www.google.com"))
Output: [Google](https://www.google.com)
Example (MdList) ¶
fmt.Println(mdList("First item", "Second item", "Third item"))
Output: - First item - Second item - Third item
Example (MdQuote) ¶
fmt.Println(mdQuote("Hello, World!"))
Output: > Hello, World!
Example (MdStrike) ¶
fmt.Println(mdStrike("This is a strikethrough."))
Output: ~~This is a strikethrough.~~
Example (MdTableHeader) ¶
fmt.Println(mdTableHeader("Name", "Age"))
Output: | Name | Age | | -------- | -------- |
Example (MdTableRow) ¶
fmt.Println(mdTableRow("Alice", "30"))
Output: | Alice | 30 |
Example (MdTask) ¶
fmt.Println(mdTask("This is a task."))
Output: - [ ] This is a task.
Example (MdTaskChecked) ¶
fmt.Println(mdTaskChecked("This is a completed task."))
Output: - [x] This is a completed task.
Example (Mod) ¶
fmt.Println(mod(7, 3))
Output: 1
Example (Mul) ¶
fmt.Println(mul(2, 3))
Output: 6
Example (StripNewLines) ¶
fmt.Println(stripNewLines("Hello\n\nWorld")) fmt.Println(stripNewLines("Hello World"))
Output: Hello World Hello World
Example (Sub) ¶
fmt.Println(sub(3, 2))
Output: 1
Example (UppercaseFirstCharacter) ¶
fmt.Println(uppercaseFirstCharacter("hello")) fmt.Println(uppercaseFirstCharacter("Hello")) fmt.Println(uppercaseFirstCharacter(""))
Output: Hello Hello
Index ¶
Examples ¶
- Package (Add)
- Package (Div)
- Package (LowercaseFirstCharacter)
- Package (MdBold)
- Package (MdCode)
- Package (MdEmoji)
- Package (MdFootnote)
- Package (MdFootnoteRef)
- Package (MdH1)
- Package (MdH2)
- Package (MdH3)
- Package (MdH4)
- Package (MdH5)
- Package (MdH6)
- Package (MdHR)
- Package (MdHeading)
- Package (MdImage)
- Package (MdItalic)
- Package (MdLink)
- Package (MdList)
- Package (MdQuote)
- Package (MdStrike)
- Package (MdTableHeader)
- Package (MdTableRow)
- Package (MdTask)
- Package (MdTaskChecked)
- Package (Mod)
- Package (Mul)
- Package (StripNewLines)
- Package (Sub)
- Package (UppercaseFirstCharacter)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TemplateFuncs ¶
TemplateFuncs returns the default template functions. It is not a global variable so the linker can dead code eliminate more when this isn't called (see https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/text/template/funcs.go;l=39)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.