Write the template to the buffer using this Context
(sub SubContext, f SubFormat)
| 124 | |
| 125 | // Write the template to the buffer using this Context |
| 126 | func (c *Context) Write(sub SubContext, f SubFormat) error { |
| 127 | c.buffer = &bytes.Buffer{} |
| 128 | tmpl, err := c.parseFormat() |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | subFormat := func(subContext SubContext) error { |
| 134 | return c.contextFormat(tmpl, subContext) |
| 135 | } |
| 136 | if err := f(subFormat); err != nil { |
| 137 | return err |
| 138 | } |
| 139 | |
| 140 | c.postFormat(tmpl, sub) |
| 141 | return nil |
| 142 | } |