<commit_before>package mux

import (
	"fmt"
	"gondola/template"
	"io"
	"net/http"
	"reflect"
)

var reservedVariables = []string{"Context", "Request"}

type Template interface {
	Execute(w io.Writer, data interface{}) error
	ExecuteVars(w io.Writer, data interface{}, vars map[string]interface{}) error
}

type TemplateProcessor func(*template.Template) (*template.Template, error)

type tmpl struct {
	*template.Template
	mux *Mux
}

func newTemplate(mux *Mux) *tmpl {
	t := &tmpl{}
	t.mux = mux
	t.Template = template.New(mux.templatesLoader, mux.assetsManager)
	t.Template.Funcs(template.FuncMap{
		"reverse": makeReverse(t),
	})
	return t
}

func (t *tmpl) ParseVars(file string, vars template.VarMap) error {
	for _, k := range reservedVariables {
		vars[k] = nil
	}
	return t.Template.ParseVars(file, vars)
}

func (t *tmpl) execute(w io.Writer, data interface{}, vars template.VarMap) error {
	var context *Context
	var request *http.Request
	if context, _ = w.(*Context); context != nil {
		request = context.R
	}
	va := map[string]interface{}{<commit_msg>Avoid panic when calling ParseVars with nil variables<commit_after>package mux

import (
	"fmt"
	"gondola/template"
	"io"
	"net/http"
	"reflect"
)

var reservedVariables = []string{"Context", "Request"}

type Template interface {
	Execute(w io.Writer, data interface{}) error
	ExecuteVars(w io.Writer, data interface{}, vars map[string]interface{}) error
}

type TemplateProcessor func(*template.Template) (*template.Template, error)

type tmpl struct {
	*template.Template
	mux *Mux
}

func newTemplate(mux *Mux) *tmpl {
	t := &tmpl{}
	t.mux = mux
	t.Template = template.New(mux.templatesLoader, mux.assetsManager)
	t.Template.Funcs(template.FuncMap{
		"reverse": makeReverse(t),
	})
	return t
}

func (t *tmpl) ParseVars(file string, vars template.VarMap) error {
	if vars != nil {
		for _, k := range reservedVariables {
			vars[k] = nil
		}
	}
	return t.Template.ParseVars(file, vars)
}

func (t *tmpl) execute(w io.Writer, data interface{}, vars template.VarMap) error {
	var context *Context
	var request *http.Request
	if context, _ = w.(*Context); context != nil {
		request = context.R
	}
	va := map[string]interface{}{
{'fraction_non_alphanumeric': 0.1395985401459854, 'fraction_numerical': 0.0, 'mean_word_length': 4.696103896103896, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '865246', 'n_tokens_mistral': 763, 'n_tokens_neox': 758, 'n_words': 201}