paths

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathForKey = "pathFor"
)

Keys to be used in templates for the functions in this package.

Variables

This section is empty.

Functions

func New

func New() hctx.Map

New returns a map of the helpers within this package.

func PathFor

func PathFor(in interface{}) (string, error)

PathFor takes an `interface{}`, or a `slice` of them, and tries to convert it to a `/foos/{id}` style URL path. Rules: * if `string` it is returned as is * if `Pathable` the `ToPath` method is returned * if `slice` or an `array` each element is run through the helper then joined * if `struct` the name of the struct, pluralized is used for the name * if `Paramable` the `ToParam` method is used to fill the `{id}` slot * if `struct.Slug` the slug is used to fill the `{id}` slot of the URL * if `struct.ID` the ID is used to fill the `{id}` slot of the URL

Types

type Paramable

type Paramable interface {
	ToParam() string
}

type Pathable

type Pathable interface {
	ToPath() string
}

Jump to

Keyboard shortcuts

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