// ExecuteRaw receives, parse and executes raw source template contents
// it's super-simple function without options and funcs, it's not used widely
// implements the EngineRawExecutor interface
32
func (p *Engine) ExecuteRaw(src string, wr io.Writer, binding interface{}) (err error) {
	set := pongo2.NewSet("", pongo2.DefaultLoader)
	set.Globals = getPongoContext(p.Config.Globals)
	tmpl, err := set.FromString(src)
	if err != nil {
		return err
	}
	return tmpl.ExecuteWriter(getPongoContext(binding), wr)
}
797445
func (s *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) error {
	layout := s.Config.Layout

	if len(options) > 0 {
		layoutOpt := options[0]["layout"]
		if layoutOpt != nil {
			if l, ok := layoutOpt.(string); ok {
				if l != "" {
					layout = l
				}
			}
		}
	}

	if layout != "" && layout != NoLayout {
		s.layoutFuncsFor(name, binding)
		name = layout
	} else {
		s.runtimeFuncsFor(name, binding)
	}

	return s.Templates.ExecuteTemplate(out, name, binding)
}
232036
func (q *query) ExecuteBatch(ctx context.Context, request *querypb.ExecuteBatchRequest) (response *querypb.ExecuteBatchResponse, err error) {
	defer q.server.HandlePanic(&err)
	ctx = callerid.NewContext(callinfo.GRPCCallInfo(ctx),
		request.EffectiveCallerId,
		request.ImmediateCallerId,
	)
	results, err := q.server.ExecuteBatch(ctx, request.Target, request.Queries, request.AsTransaction, request.TransactionId, request.Options)
	if err != nil {
		return nil, vterrors.ToGRPC(err)
	}
	return &querypb.ExecuteBatchResponse{
		Results: sqltypes.ResultsToProto3(results),
	}, nil
}
857569
func ExecuteTemplate(key string, templateDefinition string, model interface{}) ([]byte, error) {
	t := template.New(key)

	_, err := t.Parse(templateDefinition)
	if err != nil {
		return nil, fmt.Errorf("error parsing template %q: %v", key, err)
	}

	t.Option("missingkey=zero")

	var buffer bytes.Buffer
	err = t.ExecuteTemplate(&buffer, key, model)
	if err != nil {
		return nil, fmt.Errorf("error executing template %q: %v", key, err)
	}

	return buffer.Bytes(), nil
}
35060
func (b *Bucket) SetRaw(k string, exp int, v []byte) error {
	return b.Write(k, 0, exp, v, Raw)
}
776350
func (s *Server) HandlePostRaw(w http.ResponseWriter, r *http.Request) {
	ruid := GetRUID(r.Context())
	log.Debug("handle.post.raw", "ruid", ruid)

	postRawCount.Inc(1)

	toEncrypt := false
	uri := GetURI(r.Context())
	if uri.Addr == "encrypt" {
		toEncrypt = true
	}

	if uri.Path != "" {
		postRawFail.Inc(1)
		respondError(w, r, "raw POST request cannot contain a path", http.StatusBadRequest)
		return
	}

	if uri.Addr != "" && uri.Addr != "encrypt" {
		postRawFail.Inc(1)
		respondError(w, r, "raw POST request addr can only be empty or \"encrypt\"", http.StatusBadRequest)
		return
	}

	if r.Header.Get("Content-Length") == "" {
		postRawFail.Inc(1)
		respondError(w, r, "missing Content-Length header in request", http.StatusBadRequest)
		return
	}

	addr, _, err := s.api.Store(r.Context(), r.Body, r.ContentLength, toEncrypt)
	if err != nil {
		postRawFail.Inc(1)
		respondError(w, r, err.Error(), http.StatusInternalServerError)
		return
	}

	log.Debug("stored content", "ruid", ruid, "key", addr)

	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, addr)
}
1101796
func (o Options) AddRaw(key OptionCode, value []byte) {
	o[key] = append(o[key], value)
}
182718
func (obj *Global) EngineVersionRaw(ctx context.Context) (json.RawMessage, error) {
	result := &struct {
		Version json.RawMessage	`json:"qVersion"`
	} {}
	err := obj.rpc(ctx, "EngineVersion", result)
	return result.Version, err 
}
708703
func (itc *internalTabletConn) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, transactionID int64, options *querypb.ExecuteOptions) ([]sqltypes.Result, error) {
	q := make([]*querypb.BoundQuery, len(queries))
	for i, query := range queries {
		q[i] = &querypb.BoundQuery{
			Sql:           query.Sql,
			BindVariables: sqltypes.CopyBindVariables(query.BindVariables),
		}
	}
	results, err := itc.tablet.qsc.QueryService().ExecuteBatch(ctx, target, q, asTransaction, transactionID, options)
	if err != nil {
		return nil, tabletconn.ErrorFromGRPC(vterrors.ToGRPC(err))
	}
	return results, nil
}
1285308
func (m *MockConnector) PublishRaw(target string, data []byte) error {
	ret := m.ctrl.Call(m, "PublishRaw", target, data)
	ret0, _ := ret[0].(error)
	return ret0
}
189890
func (r *T) RawExec(args ...string) (string, error) {
	out, err := exec.Command(r.Cmd, args...).CombinedOutput()
	if err == nil {
		out = bytes.TrimSpace(out)
	}
	if err != nil {
		err = &Error{
			Tool:   r.Cmd,
			Output: out,
			Err:    err,
		}
	}
	return string(out), err
}
1161194
func (r *selectResult) NextRaw(ctx context.Context) ([]byte, error) {
	re := <-r.results
	r.partialCount++
	r.feedback.Invalidate()
	if re.result == nil || re.err != nil {
		return nil, errors.Trace(re.err)
	}
	return re.result.GetData(), nil
}
1335990
func ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) (err error) {
	return DefaultMux.ExecuteWriter(out, name, binding, options...)
}
1292897
func (m *Mux) ExecuteWriter(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) (err error) {
	if m == nil {
		//file extension, but no template engine registered
		return errNoTemplateEngineForExt.Format(filepath.Ext(name))
	}

	entry := m.Entries.Find(name)
	if entry == nil {
		return errTemplateNotFound.Format(name)
	}

	if m.Reload {
		if err = entry.LoadEngine(); err != nil {
			return
		}
	}

	return entry.Engine.ExecuteWriter(out, name, binding, options...)
}
1119752
func (conn *Connection) PublishRaw(target string, data []byte) error {
	log.Debugf("Publishing %d bytes to %s", len(data), target)

	return conn.nats.Publish(target, data)
}
531321
func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bindingData interface{}) error {
	// re-parse the templates if reload is enabled.
	if s.reload {
		// locks to fix #872, it's the simplest solution and the most correct,
		// to execute writers with "wait list", one at a time.
		s.rmu.Lock()
		defer s.rmu.Unlock()
		if err := s.Load(); err != nil {
			return err
		}
	}

	layout = getLayout(layout, s.layout)

	if layout != "" {
		s.layoutFuncsFor(name, bindingData)
		name = layout
	} else {
		s.runtimeFuncsFor(name, bindingData)
	}

	return s.Templates.ExecuteTemplate(w, name, bindingData)
}
911114
func (t Renderer) Execute(wr io.Writer, obj data.Map) (err error) {
	if t.tofu == nil || t.tofu.registry == nil {
		return errors.New("Template Registry required")
	}
	if t.name == "" {
		return errors.New("Template name required")
	}

	var tmpl, ok = t.tofu.registry.Template(t.name)
	if !ok {
		return ErrTemplateNotFound
	}

	var autoescapeMode = tmpl.Namespace.Autoescape
	if autoescapeMode == ast.AutoescapeUnspecified {
		autoescapeMode = ast.AutoescapeOn
	}

	var initialScope = newScope(obj)
	initialScope.enter()

	state := &state{
		tmpl:       tmpl,
		registry:   *t.tofu.registry,
		namespace:  tmpl.Namespace.Name,
		autoescape: autoescapeMode,
		wr:         wr,
		context:    initialScope,
		ij:         t.ij,
		msgs:       t.msgs,
	}
	defer state.errRecover(&err)
	state.walk(tmpl.Node)
	return
}