2018-11-18 09:28:26 +00:00
|
|
|
package tmpl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
)
|
|
|
|
|
2018-11-19 23:06:15 +00:00
|
|
|
type Fragment struct {
|
|
|
|
Body string
|
|
|
|
TemplateName string
|
|
|
|
Index int
|
|
|
|
Seen bool
|
|
|
|
}
|
|
|
|
|
2018-11-18 09:28:26 +00:00
|
|
|
type OutBufferFrame struct {
|
|
|
|
Body string
|
|
|
|
Type string
|
|
|
|
TemplateName string
|
2018-11-19 23:06:15 +00:00
|
|
|
Extra interface{}
|
|
|
|
Extra2 interface{}
|
2018-11-18 09:28:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CContext struct {
|
|
|
|
VarHolder string
|
|
|
|
HoldReflect reflect.Value
|
|
|
|
TemplateName string
|
|
|
|
OutBuf *[]OutBufferFrame
|
|
|
|
}
|
|
|
|
|
2018-11-19 23:06:15 +00:00
|
|
|
func (con *CContext) Push(nType string, body string) (index int) {
|
|
|
|
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{body, nType, con.TemplateName, nil, nil})
|
|
|
|
return len(*con.OutBuf) - 1
|
2018-11-18 09:28:26 +00:00
|
|
|
}
|
|
|
|
|
2018-11-19 23:06:15 +00:00
|
|
|
func (con *CContext) PushText(body string, fragIndex int, fragOutIndex int) (index int) {
|
|
|
|
*con.OutBuf = append(*con.OutBuf, OutBufferFrame{body, "text", con.TemplateName, fragIndex, fragOutIndex})
|
|
|
|
return len(*con.OutBuf) - 1
|
2018-11-18 09:28:26 +00:00
|
|
|
}
|