hugo: Index | Files

package resources

import ""

Package resources provides template functions for working with resources.


Package Files

init.go resources.go

type Namespace Uses

type Namespace struct {
    // contains filtered or unexported fields

Namespace provides template functions for the "resources" namespace.

func New Uses

func New(deps *deps.Deps) (*Namespace, error)

New returns a new instance of the resources-namespaced template functions.

func (*Namespace) Babel Uses

func (ns *Namespace) Babel(args ...interface{}) (resource.Resource, error)

Babel processes the given Resource with Babel.

func (*Namespace) Concat Uses

func (ns *Namespace) Concat(targetPathIn interface{}, r interface{}) (resource.Resource, error)

Concat concatenates a slice of Resource objects. These resources must (currently) be of the same Media Type.

func (*Namespace) ExecuteAsTemplate Uses

func (ns *Namespace) ExecuteAsTemplate(args ...interface{}) (resource.Resource, error)

ExecuteAsTemplate creates a Resource from a Go template, parsed and executed with the given data, and published to the relative target path.

func (*Namespace) Fingerprint Uses

func (ns *Namespace) Fingerprint(args ...interface{}) (resource.Resource, error)

Fingerprint transforms the given Resource with a MD5 hash of the content in the RelPermalink and Permalink.

func (*Namespace) FromString Uses

func (ns *Namespace) FromString(targetPathIn, contentIn interface{}) (resource.Resource, error)

FromString creates a Resource from a string published to the relative target path.

func (*Namespace) Get Uses

func (ns *Namespace) Get(filename interface{}) (resource.Resource, error)

Get locates the filename given in Hugo's assets filesystem and creates a Resource object that can be used for further transformations.

func (*Namespace) GetMatch Uses

func (ns *Namespace) GetMatch(pattern interface{}) (resource.Resource, error)

GetMatch finds the first Resource matching the given pattern, or nil if none found.

It looks for files in the assets file system.

See Match for a more complete explanation about the rules used.

func (*Namespace) Match Uses

func (ns *Namespace) Match(pattern interface{}) (resource.Resources, error)

Match gets all resources matching the given base path prefix, e.g "*.png" will match all png files. The "*" does not match path delimiters (/), so if you organize your resources in sub-folders, you need to be explicit about it, e.g.: "images/*.png". To match any PNG image anywhere in the bundle you can do "**.png", and to match all PNG images below the images folder, use "images/**.jpg".

The matching is case insensitive.

Match matches by using the files name with path relative to the file system root with Unix style slashes (/) and no leading slash, e.g. "images/logo.png".

See for the full rules set.

It looks for files in the assets file system.

See Match for a more complete explanation about the rules used.

func (*Namespace) Minify Uses

func (ns *Namespace) Minify(r resources.ResourceTransformer) (resource.Resource, error)

Minify minifies the given Resource using the MediaType to pick the correct minifier.

func (*Namespace) PostCSS Uses

func (ns *Namespace) PostCSS(args ...interface{}) (resource.Resource, error)

PostCSS processes the given Resource with PostCSS

func (*Namespace) PostProcess Uses

func (ns *Namespace) PostProcess(r resource.Resource) (postpub.PostPublishedResource, error)

func (*Namespace) ToCSS Uses

func (ns *Namespace) ToCSS(args ...interface{}) (resource.Resource, error)

ToCSS converts the given Resource to CSS. You can optional provide an Options object or a target path (string) as first argument.

Package resources imports 19 packages (graph) and is imported by 20 packages. Updated 2020-07-15. Refresh now. Tools for package owners.