Backward

The Backward registry offers functions to maintain compatibility with older Sprig versions, ensuring legacy templates continue to work seamlessly after updates.

You can easily import all the functions from the backward registry by including the following import statement in your code

import "github.com/go-sprout/sprout/registry/backward"

Deprecated functions

fail ⚠️

The Fail function creates an error with a specified message and returns a nil pointer along with the error. It is generally used to indicate failure in functions that return both a pointer and an error.

[DEPRECATED] No replacement are scheduled yet. If you need this function, open an issue to clearly explain the usage.

Signature

Fail(message string) (*uint, error)
{{ fail "Operation failed" }} // Output: nil, error with "Operation failed"

urlParse ⚠️

The function parses a given URL string and returns a map containing its components, such as the scheme, host, path, query parameters, and more, allowing easy access and manipulation of the different parts of a URL.

[DEPRECATED] No replacement are scheduled yet. If you need this function, open an issue to clearly explain the usage.

Signature

UrlParse(v string) (map[string]any, error)
{{ "https://example.com/path?query=1#fragment" | urlParse }}
// Output: map[fragment:fragment host:example.com hostname:example.com path:path query:query scheme:https]

urlJoin ⚠️

The function constructs a URL string from a given map of URL components, assembling the various parts such as scheme, host, path, and query parameters into a complete URL.

[DEPRECATED] No replacement are scheduled yet. If you need this function, open an issue to clearly explain the usage.

Signature

UrlJoin(d map[string]any) (string, error)
{{ dict scheme="https" host="example.com" path="/path" query="query=1" opaque="opaque" fragment="fragment" | urlJoin }}
// Output: "https://example.com/path?query=1#fragment"

getHostByName⚠️

The function returns a random IP address associated with a given hostname, providing a way to resolve a hostname to one of its corresponding IP addresses.

[DEPRECATED] No replacement are scheduled yet. If you need this function, open an issue to clearly explain the usage.

Signature

GetHostByName(name string) (string, error)
{{ getHostByName "localhost" }} // Output: "127.0.0.1"

Last updated