helpers: Index | Files

package paths

import ""


Package Files

path_for.go paths.go


const (
    PathForKey = "pathFor"

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

func New Uses

func New() hctx.Map

New returns a map of the helpers within this package.

func PathFor Uses

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 Uses

type Paramable interface {
    ToParam() string

type Pathable Uses

type Pathable interface {
    ToPath() string

Package paths imports 9 packages (graph) and is imported by 4 packages. Updated 2019-07-02. Refresh now. Tools for package owners.