Skip to content

Commit

Permalink
Add exposed versions of getTemplate and runTemplate
Browse files Browse the repository at this point in the history
GetTemplate and RunTemplate allow external users to access the template system,
and in particular allow them to provide their own Buffer to write the output to.

I've implemented exposed versions calling the private functions, rather than breaking
the internal API. If this isn't a concern, we should remove getTemplate and runTemplate
in a future commit.
  • Loading branch information
Mike Pountney committed Dec 31, 2015
1 parent 408743b commit da6cbd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func (c *Cli) makeRequest(req *http.Request) (resp *http.Response, err error) {
return resp, nil
}

func (c *Cli) GetTemplate(name string) string {
return c.getTemplate(name)
}

func (c *Cli) getTemplate(name string) string {
if override, ok := c.opts["template"].(string); ok {
if _, err := os.Stat(override); err == nil {
Expand Down
5 changes: 4 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ func dateFormat(format string, content string) (string, error) {
}
}

func runTemplate(templateContent string, data interface{}, out io.Writer) error {
func RunTemplate(templateContent string, data interface{}, out io.Writer) error {
return runTemplate(templateContent, data, out)
}

func runTemplate(templateContent string, data interface{}, out io.Writer) error {
if out == nil {
out = os.Stdout
}
Expand Down

0 comments on commit da6cbd5

Please sign in to comment.