本文整理匯總了Golang中github.com/karlseguin/gerb/core.Parser.TagContains方法的典型用法代碼示例。如果您正苦於以下問題:Golang Parser.TagContains方法的具體用法?Golang Parser.TagContains怎麽用?Golang Parser.TagContains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/karlseguin/gerb/core.Parser
的用法示例。
在下文中一共展示了Parser.TagContains方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: IfFactory
func IfFactory(p *core.Parser) (core.Code, error) {
code := &IfCode{
NormalContainer: new(core.NormalContainer),
assignments: make([]*core.Assignment, 0, 3),
verifiables: make([]core.Verifiable, 0, 3),
codes: make([]core.Code, 0, 3),
}
if p.TagContains(';') {
assignment, err := p.ReadAssignment()
if err != nil {
return nil, err
}
code.assignments = append(code.assignments, assignment)
if p.SkipSpaces() != ';' {
return nil, p.Error("If assignment should be followed by a semicolon")
}
p.Next()
} else {
code.assignments = append(code.assignments, nil)
}
verifiable, err := p.ReadConditionGroup(false)
if err != nil {
return nil, err
}
code.verifiables = append(code.verifiables, verifiable)
code.codes = append(code.codes, code)
if p.SkipSpaces() != '{' {
return nil, p.Error("Missing openening brace for if statement")
}
p.Next()
return code, nil
}
示例2: ElseFactory
func ElseFactory(p *core.Parser) (core.Code, error) {
code := &ElseCode{NormalContainer: new(core.NormalContainer)}
if p.SkipSpaces() == 'i' && p.ConsumeIf([]byte("if")) {
if p.TagContains(';') {
assignment, err := p.ReadAssignment()
if err != nil {
return nil, err
}
code.assignment = assignment
if p.SkipSpaces() != ';' {
return nil, p.Error("else if assignment should be followed by a semicolon")
}
p.Next()
}
verifiable, err := p.ReadConditionGroup(false)
if err != nil {
return nil, err
}
code.verifiable = verifiable
if p.SkipSpaces() != '{' {
return nil, p.Error("Missing openening brace for else if statement")
}
} else {
code.verifiable = core.TrueCondition //else case
if p.SkipSpaces() != '{' {
return nil, p.Error("Missing openening brace for else statement")
}
}
p.Next()
return code, nil
}
示例3: ForFactory
func ForFactory(p *core.Parser) (core.Code, error) {
if p.TagContains(';') {
return ExplicitForFactory(p)
}
if p.SkipSpaces() == '{' {
p.Next()
return &ForCode{NormalContainer: new(core.NormalContainer)}, nil
}
return RangedForFactory(p)
}