mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
Add exposed versions of getTemplate and runTemplate
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.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user