template

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingBody = errors.New("if the first line is '---' you have to include a yaml header as described in the atwhy readme")
)

Functions

This section is empty.

Types

type Header struct {
	// Meta contains additional data which can be used by the generators.
	// It is also available inside the template for example with
	//  {{ .Meta.Title }}
	Meta MetaData `yaml:"meta"`

	Server ServerData `yaml:"server"`
}

type Loader

type Loader struct {
	FS                afero.Fs
	ProjectPathPrefix string
}

func (Loader) Load

func (l Loader) Load(tags []tag.Tag) ([]Markdown, error)

Load templates from the Loader.FS.

type Markdown

type Markdown struct {
	ID                string
	ProjectPathPrefix string
	Name              string
	Path              string
	Header            Header
	// contains filtered or unexported fields
}

Markdown

@WHY doc_template_usage The templates should be markdown files with a yaml header for metadata.

You can access a tag called `\@WHY example_tag` using

# Example
{{ .Escape
"{{ .Tag.example_tag }}"
}}

Note: This uses the Go templating engine. Therefore you can use the [Go templating syntax](https://learn.hashicorp.com/tutorials/nomad/go-template-syntax?in=nomad/templates).

func TestTemplate added in v0.7.0

func TestTemplate(fields Markdown, templateStr string) Markdown

func (Markdown) Execute

func (t Markdown) Execute(writer io.Writer) error

Execute the template

type MetaData

type MetaData struct {
	// Title is for example used in the html generator to create the navigation buttons.
	// If not set, it will default to the template file-name (excluding .tpl.md)
	Title string `yaml:"title"`
}

type ServerData

type ServerData struct {
	// Index defines if this template should be used as "index.html".
	// Note that there can only be one page in each folder which is the index.
	Index bool `yaml:"index"`
}

Jump to

Keyboard shortcuts

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