tpls

Extendable, Fast Template Engine for Go
git clone git://git.lair.cx/tpls
Log | Files | Refs | README | LICENSE

builtin_for.go (411B)


      1 package tplc
      2 
      3 import (
      4 	"strings"
      5 
      6 	"go.lair.cx/go-core/net/htmlx"
      7 )
      8 
      9 func TagFor(b *Builder, w *Writer, t *htmlx.Tokenizer) error {
     10 	attrs := getAttrs(t)
     11 	className, ok := attrs["class"]
     12 	if ok {
     13 		w.WriteGoCode("for ", strings.TrimSpace(className), " {\n")
     14 	} else {
     15 		w.WriteGoCode("for {\n")
     16 	}
     17 
     18 	err := RenderTag(b, w, t, "for", false)
     19 	if err != nil {
     20 		return err
     21 	}
     22 
     23 	w.WriteGoCode("}\n")
     24 	return nil
     25 }