Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StrTmpl ¶ added in v0.4.0
type StrTmpl struct {
// contains filtered or unexported fields
}
func MustNewStrTmpl ¶ added in v0.4.0
MustNewStrTmpl creates a new StrTmpl from the provided raw template string. It takes tmplRaw of type string. It returns a pointer to StrTmpl. It panics if there is an error during the creation of the StrTmpl.
func NewStrTmpl ¶ added in v0.4.0
NewStrTmpl creates a new StrTmpl instance by parsing the provided template string. It takes tmpl of type string, which is the template to be parsed. It returns a pointer to StrTmpl and an error. It returns an error if the template parsing fails.
func (*StrTmpl) Execute ¶ added in v0.4.0
Execute processes the given parameters using a JSON template and returns the resulting string. It takes params of type any, which represents the data to be used in the template. It returns a string containing the processed template and an error if the operation fails. It returns an error if the parameters cannot be marshaled into JSON, if the template execution fails, or if the template path does not resolve to a string.
type Tmpl ¶
type Tmpl struct {
// contains filtered or unexported fields
}
func MustNewTmpl ¶ added in v0.3.0
MustNewTmpl creates a new Tmpl instance from the provided raw template string. It takes tmplRaw of type string, which is the raw template content. It returns a pointer to a Tmpl instance. It panics if there is an error during the creation of the Tmpl instance.
func New ¶
New creates a new Tmpl instance from a raw JSON template string. It takes tmplRaw of type string, which is the raw JSON template. It returns a pointer to Tmpl and an error. It returns an error if the template parsing fails.
func (*Tmpl) Execute ¶
Execute processes the provided data using the template and returns the result as a byte slice. It takes one parameter: data of type []byte, which represents the input data to be processed by the template. It returns a byte slice containing the processed data and an error if the template execution fails. It returns an error if the template execution encounters any issues, such as invalid data or template errors.
type URLTmpl ¶ added in v0.3.0
type URLTmpl struct {
// contains filtered or unexported fields
}
func MustNewURLTmpl ¶ added in v0.3.0
MustNewURLTmpl creates a new URLTmpl from the given raw template string. It takes tmplRaw of type string. It returns a pointer to a URLTmpl. It panics if the template string is invalid or if there is an error during the creation of the URLTmpl.
func NewURLTmpl ¶ added in v0.3.0
NewURLTmpl creates a new URLTmpl instance by parsing the provided template string. It takes tmpl of type string, which represents the template to be parsed. It returns a pointer to a URLTmpl and an error. It returns an error if the template parsing fails.
func (*URLTmpl) Execute ¶ added in v0.3.0
Execute generates a URL string by executing a template with the provided parameters. It takes params of type any, which are marshaled into JSON and used to fill the template. It returns a string containing the generated URL and an error if the operation fails. It returns an error if the parameters cannot be marshaled into JSON, if the template execution fails, or if the template path does not resolve to a string value.