tmpl

package
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

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:

![Gopher](https://golang.org/doc/gopher/frontpage.png)
Example (MdItalic)
fmt.Println(mdItalic("Hello, World!"))
Output:

*Hello, World!*
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

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateFuncs

func TemplateFuncs() template.FuncMap

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL