本文整理汇总了Golang中github.com/karlseguin/liquid/core.Parser.ReadValue方法的典型用法代码示例。如果您正苦于以下问题:Golang Parser.ReadValue方法的具体用法?Golang Parser.ReadValue怎么用?Golang Parser.ReadValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/karlseguin/liquid/core.Parser
的用法示例。
在下文中一共展示了Parser.ReadValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CaseFactory
func CaseFactory(p *core.Parser, config *core.Configuration) (core.Tag, error) {
value, err := p.ReadValue()
if err != nil {
return nil, err
}
p.SkipPastTag()
return &Case{value, make([]CaseSibling, 0, 5)}, nil
}
示例2: 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
}
示例3: newOutput
func newOutput(p *core.Parser) (core.Code, error) {
p.ForwardBy(2) // skip the {{
value, err := p.ReadValue()
if err != nil || value == nil {
return nil, err
}
filters, err := p.ReadFilters()
if err != nil {
return nil, err
}
p.SkipPastOutput()
return &Output{value, filters}, nil
}
示例4: 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
}
示例5: 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
}