本文整理匯總了Golang中github.com/get3w/get3w/engines/liquid/core.Parser.Error方法的典型用法代碼示例。如果您正苦於以下問題:Golang Parser.Error方法的具體用法?Golang Parser.Error怎麽用?Golang Parser.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/get3w/get3w/engines/liquid/core.Parser
的用法示例。
在下文中一共展示了Parser.Error方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CaptureFactory
// Creates an assign tag
func CaptureFactory(p *core.Parser, config *core.Configuration) (core.Tag, error) {
name := p.ReadName()
if len(name) == 0 {
return nil, p.Error("Invalid assignment, variable not found. ")
}
p.SkipPastTag()
return &Capture{name, NewCommon()}, nil
}
示例2: ForFactory
func ForFactory(p *core.Parser, config *core.Configuration) (core.Tag, error) {
name := p.ReadName()
if len(name) == 0 {
return nil, p.Error("Invalid variable name in for tag")
}
if p.SkipSpaces() != 'i' || p.Left() < 3 || p.Data[p.Position+1] != 'n' || !core.IsTokenEnd(p.Data[p.Position+2]) {
return nil, p.Error("Expecting keyword 'in' after variable name in for tag")
}
p.ForwardBy(2)
value, err := p.ReadValue()
if err != nil {
return nil, err
}
f := &For{
Common: NewCommon(),
name: name,
keyName: name + "[0]",
valueName: name + "[1]",
value: value,
}
for {
name := p.ReadName()
if name == "" {
break
}
if name == "limit" {
if p.SkipUntil(':') != ':' {
return nil, p.Error("Expecting ':' after limit in for tag")
}
p.Forward()
limit, err := p.ReadValue()
if err != nil {
return nil, err
}
f.limit = limit
} else if name == "offset" {
if p.SkipUntil(':') != ':' {
return nil, p.Error("Expecting ':' after offset in for tag")
}
p.Forward()
offset, err := p.ReadValue()
if err != nil {
return nil, err
}
f.offset = offset
} else if name == "reverse" {
f.reverse = true
} else {
return nil, p.Error(fmt.Sprint("%q is an inknown modifier in for tag", name))
}
}
p.SkipPastTag()
return f, nil
}
示例3: IncludeFactory
// Creates an include tag
func IncludeFactory(p *core.Parser, config *core.Configuration) (core.Tag, error) {
value, err := p.ReadValue()
if err != nil {
return nil, err
}
if value == nil {
return nil, p.Error("Invalid include value")
}
p.SkipPastTag()
return &Include{value, config.GetIncludeHandler()}, nil
}
示例4: extractTokens
func extractTokens(parser *core.Parser, container core.Tag, config *core.Configuration) error {
stack := []core.Tag{container}
preserveWhiteSpace := config.GetPreserveWhitespace()
for parser.HasMore() {
pre, markupType := parser.ToMarkup(preserveWhiteSpace)
if len(pre) > 0 {
container.AddCode(newLiteral(pre))
}
if markupType == core.OutputMarkup {
code, err := newOutput(parser)
if err != nil {
return err
}
if code != nil {
container.AddCode(code)
}
} else if markupType == core.TagMarkup {
tag, err := newTag(parser, config)
if err != nil {
return err
}
switch tag.Type() {
case core.ContainerTag, core.LoopTag:
container.AddCode(tag)
container = tag
stack = append(stack, container)
case core.EndTag:
l := len(stack) - 1
container = stack[l]
if tag.Name() != container.Name() {
return parser.Error(fmt.Sprintf("end tag \"end%s\" cannot terminate %q", tag.Name(), container.Name()))
}
stack = stack[0:l]
container = stack[l-1]
parser.SkipPastTag()
case core.SiblingTag:
if err := stack[len(stack)-1].AddSibling(tag); err != nil {
return err
}
container = tag
case core.StandaloneTag:
container.AddCode(tag)
}
} else {
break
}
}
return nil
}
示例5: AssignFactory
// Creates an assign tag
func AssignFactory(p *core.Parser, config *core.Configuration) (core.Tag, error) {
name := p.ReadName()
if len(name) == 0 {
return nil, p.Error("Invalid variable name in assign tag")
}
if p.SkipUntil('=') != '=' {
return nil, p.Error("Invalid assign, missing '=' ")
}
p.Forward()
value, err := p.ReadValue()
if err != nil {
return nil, err
}
filters, err := p.ReadFilters()
if err != nil {
return nil, err
}
p.SkipPastTag()
return &Assign{name, value, filters}, nil
}