diff --git a/lexer.go b/lexer.go index 4040c56..9777079 100644 --- a/lexer.go +++ b/lexer.go @@ -51,6 +51,7 @@ type ( Val string Line int Col int + Position int TrimWhitespaces bool } ) @@ -107,7 +108,7 @@ func (t *Token) String() string { typ, t.Typ, val, t.Line, t.Col, t.TrimWhitespaces) } -func lex(name string, input string) ([]*Token, *Error) { +func Lex(name string, input string) ([]*Token, *Error) { l := &lexer{ name: name, input: input, @@ -146,6 +147,7 @@ func (l *lexer) emit(t TokenType) { Val: l.value(), Line: l.startline, Col: l.startcol, + Position: l.pos, } if t == TokenString { diff --git a/template.go b/template.go index f96b3f4..8343128 100644 --- a/template.go +++ b/template.go @@ -74,7 +74,7 @@ func newTemplate(set *TemplateSet, name string, isTplString bool, tpl []byte) (* t.Options.Update(set.Options) // Tokenize it - tokens, err := lex(name, strTpl) + tokens, err := Lex(name, strTpl) if err != nil { return nil, err }