nodes_html.go 392 B

1234567891011121314151617181920212223
  1. package pongo2
  2. import (
  3. "strings"
  4. )
  5. type nodeHTML struct {
  6. token *Token
  7. trimLeft bool
  8. trimRight bool
  9. }
  10. func (n *nodeHTML) Execute(ctx *ExecutionContext, writer TemplateWriter) *Error {
  11. res := n.token.Val
  12. if n.trimLeft {
  13. res = strings.TrimLeft(res, tokenSpaceChars)
  14. }
  15. if n.trimRight {
  16. res = strings.TrimRight(res, tokenSpaceChars)
  17. }
  18. writer.WriteString(res)
  19. return nil
  20. }