good morning!!!!

Skip to content
Snippets Groups Projects
Commit 0882540e authored by Garet Halliday's avatar Garet Halliday
Browse files

add formatter

parent def3923b
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ type Raw struct { ...@@ -7,6 +7,8 @@ type Raw struct {
Obj any Obj any
// Args will be accessible within the template as arg0, arg1, argN... // Args will be accessible within the template as arg0, arg1, argN...
Args []any Args []any
// Formatter will be called to format and validate the output of the template.
Formatter func([]byte) ([]byte, error)
// Output defines the file name to place the output of this prayer. // Output defines the file name to place the output of this prayer.
Output string Output string
...@@ -25,9 +27,13 @@ func (r *Raw) Arguments() []any { ...@@ -25,9 +27,13 @@ func (r *Raw) Arguments() []any {
} }
func (r *Raw) Format(bytes []byte) ([]byte, error) { func (r *Raw) Format(bytes []byte) ([]byte, error) {
if r.Formatter == nil {
return bytes, nil return bytes, nil
} }
return r.Formatter(bytes)
}
func (r *Raw) FileName() string { func (r *Raw) FileName() string {
return r.Output return r.Output
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment