id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c16500 | t.Visitors {
v.Leave(n)
}
} | |
c16501 | := NewTree(bytes.NewReader([]byte(input)))
return t, t.Parse()
} | |
c16502 |
break
}
t.root.Append(n)
}
t.traverse(t.root)
return nil
} | |
c16503 | err != nil {
return nil, err
}
_, err = t.expect(tokenCommentClose)
if err != nil {
return nil, err
}
return NewCommentNode(tok.value, tok.Pos), nil
case tokenEOF:
// expected end of input
return nil, nil
}
return nil, newUnexpectedTokenError(tok)
} | |
c16504 | range v.SafeFor() {
safeFor[k] = true
}
return safeValue{safeFor, v.Value()}
}
return safeValue{safeFor, val}
} | |
c16505 | vc > 0
case int:
return vc > 0
case int8:
return vc > 0
case int16:
return vc > 0
case int32:
return vc > 0
case int64:
return vc > 0
case float32:
return vc > 0
case float64:
return vc > 0
case string:
return len(vc) > 0
case decimal.Decimal:
return vc.GreaterThan(decimal.Zero)
case String... | |
c16506 | uint16, uint32, uint64:
return fmt.Sprintf("%v", vc)
case Number:
return fmt.Sprintf("%v", vc.Number())
case Boolean:
if vc.Boolean() == true {
return "1" // Twig compatibility (aka PHP compatibility)
}
case bool:
if vc == true {
return "1" // Twig compatibility (aka PHP compatibility)
}
}
retu... | |
c16507 | return values unsupported, called method \"%s\" on \"%v\"", attr, v)
}
rargs := make([]reflect.Value, len(args))
for k, v := range args {
rargs[k] = reflect.ValueOf(v)
}
if t.NumIn() != len(rargs) {
return nil, fmt.Errorf("getattr: method \"%s\" on \"%v\" expects %d parameter(s), %d given", attr, v, t.... | |
c16508 |
case reflect.Slice, reflect.Array:
return true
}
return false
} | |
c16509 |
return r.Kind() == reflect.Map
} | |
c16510 |
case reflect.Slice, reflect.Array, reflect.Map:
return true
}
return false
} | |
c16511 | v := r.MapIndex(k)
brk, err := it(k.Interface(), v.Interface(), l)
if brk || err != nil {
return i + 1, err
}
l.Index++
l.Index0++
l.Last = ln == l.Index
}
return ln, nil
default:
return 0, fmt.Errorf(`stick: unable to iterate over %s "%v"`, r.Kind(), val)
}
} | |
c16512 |
return r.Len(), nil
}
return 0, fmt.Errorf(`stick: could not get length of %s "%v"`, r.Kind(), val)
} | |
c16513 | return CoerceString(left) == CoerceString(right)
} | |
c16514 | return true, nil // break
}
return false, nil
})
if err != nil {
return false, err
}
return res, nil
} | |
c16515 | return fmt.Sprintf("%d:%d", p.Line, p.Offset)
} | |
c16516 | {
return &ModuleNode{NewBodyNode(Pos{1, 0}, nodes...), nil, name}
} | |
c16517 | = append(l.Nodes, n)
} | |
c16518 | {
return &CommentNode{NewTextNode(data, p), TrimmableNode{}}
} | |
c16519 | {
return &PrintNode{p, TrimmableNode{}, exp}
} | |
c16520 | &BlockNode{p, TrimmableNode{}, name, body, ""}
} | |
c16521 | fmt.Sprintf("Block(%s: %s)", t.Name, t.Body)
} | |
c16522 | return &IfNode{p, TrimmableNode{}, cond, body, els}
} | |
c16523 | fmt.Sprintf("If(%s: %s Else: %s)", t.Cond, t.Body, t.Else)
} | |
c16524 | {
return []Node{t.Cond, t.Body, t.Else}
} | |
c16525 | {
return &ExtendsNode{p, TrimmableNode{}, tplRef}
} | |
c16526 | p Pos) *ForNode {
return &ForNode{p, TrimmableNode{}, k, v, expr, body, els}
} | |
c16527 | else %s)", t.Key, t.Val, t.X, t.Body, t.Else)
} | |
c16528 | {
return []Node{t.X, t.Body, t.Else}
} | |
c16529 | return &IncludeNode{pos, TrimmableNode{}, tmpl, with, only}
} | |
c16530 | %s %v)", t.Tpl, t.With, t.Only)
} | |
c16531 |
return &EmbedNode{NewIncludeNode(tmpl, with, only, pos), blocks}
} | |
c16532 | with %s %v: %v)", t.Tpl, t.With, t.Only, t.Blocks)
} | |
c16533 | := range t.Blocks {
r = append(r, blk)
}
return r
} | |
c16534 |
return &UseNode{pos, TrimmableNode{}, tpl, aliases}
} | |
c16535 | }
sort.Strings(keys)
res := make([]string, l)
for i, orig := range keys {
res[i] = orig + ": " + t.Aliases[orig]
}
return fmt.Sprintf("Use(%s with %s)", t.Tpl, strings.Join(res, ", "))
}
return fmt.Sprintf("Use(%s)", t.Tpl)
} | |
c16536 | &SetNode{pos, TrimmableNode{}, varName, expr}
} | |
c16537 | fmt.Sprintf("Set(%s = %v)", t.Name, t.X)
} | |
c16538 | {
return &DoNode{pos, TrimmableNode{}, expr}
} | |
c16539 | &FilterNode{p, TrimmableNode{}, filters, body}
} | |
c16540 | fmt.Sprintf("Filter (%s): %s", strings.Join(t.Filters, "|"), t.Body)
} | |
c16541 |
return &MacroNode{p, TrimmableNode{}, name, args, body, ""}
} | |
c16542 | %s(%s): %s", t.Name, strings.Join(t.Args, ", "), t.Body)
} | |
c16543 | &ImportNode{p, TrimmableNode{}, tpl, alias}
} | |
c16544 |
return fmt.Sprintf("Import (%s as %s)", t.Tpl, t.Alias)
} | |
c16545 |
return &FromNode{p, TrimmableNode{}, tpl, imports}
} | |
c16546 |
res[i] = orig
} else {
res[i] = orig + " as " + t.Imports[orig]
}
}
return fmt.Sprintf("From %s import %s", t.Tpl, strings.Join(res, ", "))
} | |
c16547 | len(exp.Args))
for i, n := range exp.Args {
res[i] = n
}
return res
} | |
c16548 |
return &FuncExpr{pos, name, args}
} | |
c16549 | fmt.Sprintf("FuncExpr(%s, %s)", exp.Name, exp.Args)
} | |
c16550 | return fmt.Sprintf("FilterExpr(%s, %s)", exp.Name, exp.Args)
} | |
c16551 | return &FilterExpr{NewFuncExpr(name, args, pos)}
} | |
c16552 | fmt.Sprintf("TestExpr(%s, %s)", exp.Name, exp.Args)
} | |
c16553 |
return &BinaryExpr{pos, left, op, right}
} | |
c16554 | %s)", exp.Left, exp.Op, exp.Right)
} | |
c16555 |
return &UnaryExpr{pos, op, expr}
} | |
c16556 | fmt.Sprintf("UnaryExpr(%s %s)", exp.Op, exp.X)
} | |
c16557 |
return &GetAttrExpr{pos, cont, attr, args}
} | |
c16558 | exp.Attr}
for _, v := range exp.Args {
res = append(res, v)
}
return res
} | |
c16559 | return fmt.Sprintf("GetAttrExpr(%s -> %s)", exp.Cont, exp.Attr)
} | |
c16560 | return &TernaryIfExpr{pos, cond, tx, fx}
} | |
c16561 | {
return []Node{exp.Cond, exp.TrueX, exp.FalseX}
} | |
c16562 | %v", exp.Cond, exp.TrueX, exp.FalseX)
} | |
c16563 | *KeyValueExpr {
return &KeyValueExpr{pos, k, v}
} | |
c16564 | {
return fmt.Sprintf("%s: %s", exp.Key, exp.Value)
} | |
c16565 | len(exp.Elements))
for i, v := range exp.Elements {
all[i] = v
}
return all
} | |
c16566 | return &Env{loader, make(map[string]Func), make(map[string]Filter), make(map[string]Test), make([]parse.NodeVisitor, 0)}
} | |
c16567 |
return execute(tpl, out, ctx, env)
} | |
c16568 | (*parse.Tree, error) {
return env.load(name)
} | |
c16569 | &stringTemplate{name, name}, nil
} | |
c16570 | os.ErrNotExist
}
return &stringTemplate{name, v}, nil
} | |
c16571 | != nil {
return nil, err
}
return &fileTemplate{name, f}, nil
} | |
c16572 | &UnexpectedTokenError{newBaseError(actual.Pos), actual, expected}
} | |
c16573 | return &UnclosedTagError{newBaseError(start), tagName}
} | |
c16574 | &UnexpectedValueError{newBaseError(tok.Pos), tok, expected}
} | |
c16575 | filterKeys,
"last": filterLast,
"length": filterLength,
"lower": filterLower,
"merge": filterMerge,
"nl2br": filterNL2BR,
"number_format": filterNumberFormat,
"raw": filterRaw,
"replace": filterReplace,
"reverse":... | |
c16576 | := stick.CoerceNumber(val)
if 0 == n {
return n
}
return math.Abs(n)
} | |
c16577 | := stick.CoerceString(val)
return strings.ToUpper(s[:1]) + s[1:]
} | |
c16578 |
if stick.CoerceString(val) == "" {
return d
}
return val
} | |
c16579 |
return utf8.RuneCountInString(v)
}
l, _ := stick.Len(val)
// TODO: Report error
return l
} | |
c16580 | return strings.ToLower(stick.CoerceString(val))
} | |
c16581 | return strings.Title(stick.CoerceString(val))
} | |
c16582 | return strings.TrimSpace(stick.CoerceString(val))
} | |
c16583 | return strings.ToUpper(stick.CoerceString(val))
} | |
c16584 | := <-l.tokens; ok; {
l.last = v
return v
}
return l.last
} | |
c16585 | nil; {
l.state = l.state(l)
}
} | |
c16586 | 1, 0, string(i), make(chan token), nil, modeNormal, token{}, 0}
} | |
c16587 | l.offset = len(val[lpos+1:])
} else {
l.offset += len(val)
}
l.tokens <- tok
l.start = l.pos
if tok.tokenType == tokenEOF {
close(l.tokens)
l.mode = modeClosed
}
} | |
c16588 | l.input[l.pos+2:l.pos+3] != " " {
return false
}
} else if op == delimTrimWhitespace {
switch l.input[l.pos+1 : l.pos+3] {
case delimClosePrint, delimCloseTag:
return false
}
}
l.pos += len(op)
l.emit(tokenOperator)
return true
} | |
c16589 | nil, err
}
return t.parseOuterExpr(expr)
} | |
c16590 |
case tokenPunctuation:
if tok.value != "," {
return nil, newUnexpectedValueError(tok, ",")
}
case tokenParensClose:
return NewFuncExpr(name.Name, args, name.Pos), nil
default:
return nil, newUnexpectedTokenError(tok, tokenPunctuation, tokenParensClose)
}
}
} | |
c16591 | Tests: make(map[string]stick.Test),
Visitors: make([]parse.NodeVisitor, 0),
}
env.Register(NewAutoEscapeExtension())
return env
} | |
c16592 | const char *path,
int attrnamespace,
const char *attrname,
void *data,
size_t nbytes);
*/
r0, _, err := syscall.Syscall6(syscallNum, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
EXTATTR_NAMESPACE_USER, uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
uintptr(unsafe.Pointer(ptr)), uintp... | |
c16593 |
_, _, err := syscall.Syscall(syscallNum, uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
EXTATTR_NAMESPACE_USER, uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
)
if err != syscall.Errno(0) {
return err
}
return nil
} | |
c16594 | []byte) (int, error) {
return getxattr(path, name, data)
})
} | |
c16595 | []byte) (int, error) {
return lgetxattr(path, name, data)
})
} | |
c16596 | []byte) (int, error) {
return fgetxattr(f, name, data)
})
} | |
c16597 | Contrary to documentation,
// MacOS never seems to return ERANGE!
// To keep the code simple, we always check both conditions, and sometimes
// double the buffer size without it being strictly neccessary.
if err == syscall.ERANGE || read == size {
// The buffer was too small. Try again.
size <<= 1
i... | |
c16598 | return &Error{"xattr.Set", path, name, err}
}
return nil
} | |
c16599 | return &Error{"xattr.LSet", path, name, err}
}
return nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.