v0.6.7 Latest Latest

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




View Source
const (
	PathForKey = "pathFor"

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


This section is empty.


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


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