categories

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The default order by field for the list function.
	OrderBy = "created_at"
	// The default order direction field for the list function.
	OrderDirection = "desc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Categories

type Categories struct {
	Categories domain.Categories
	Pagination *pagination.Pagination
}

Categories defines the struct for returning categories and pagination back to the template.

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace defines the methods for categories to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new categories Namespace

func (*Namespace) ByName

func (ns *Namespace) ByName(name interface{}) interface{}

ByName

Obtains the category by name and returns a domain.Category type or nil if not found.

Example: {{ categoryByName "sports" }}

func (*Namespace) Find

func (ns *Namespace) Find(id interface{}) interface{}

Find

Obtains the category by ID and returns a domain.Category type or nil if not found.

Example: {{ category 123 }}

func (*Namespace) List

func (ns *Namespace) List(query params.Query) (interface{}, error)

Returns errors.TEMPLATE if the template post category failed to parse.

Example: {{ $result := categories (dict "limit" 10) }} {{ with $result.Categories }}

{{ range $category := . }}
    <h2>{{ $category.Name }}</h2>
{{ end }}
{{ else }}
    <h4>No categories found</h4>

{{ end }}

func (*Namespace) Parent

func (ns *Namespace) Parent(id interface{}) interface{}

ByParent

Obtains the category by parent and returns a domain.Category type or nil if not found.

Example: {{ categoryByParent "sports" }}

Jump to

Keyboard shortcuts

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