<commit_before>package jstmpl

import (
	"bytes"
	"go/format"
	"os"
	"text/template"

	"github.com/go-jstmpl/go-jstmpl/helpers"
	"github.com/go-jstmpl/go-jstmpl/types"
	"github.com/pkg/errors"
)

type Generator struct{}

func NewGenerator() *Generator {
	return &Generator{}
}

type FormatError struct {
	err error
}

func NewFormatError(e error) FormatError {
	return FormatError{
		err: errors.Wrap(e, "fail to format Go"),
	}
}

func (err FormatError) Error() string {
	return err.err.Error()
}

func (g *Generator) Process(model *types.Root, tmpl []byte, ext string) ([]byte, error) {
	out := bytes.NewBuffer([]byte{})
	t := template.Must(template.New("").Funcs(map[string]interface{}{
		"getEnv":                 os.Getenv,
		"add":                    helpers.Add,
		"sub":                    helpers.Sub,
		"notLast":                helpers.NotLast,
		"joinTypes":              helpers.JoinTypes,
		"serialize":              helpers.Serialize,
		"toStringLiteral":        helpers.ToStringLiteral,
		"buildURLToken":          helpers.BuildURLToken,
		"toPathLikeGorilla":      helpers.CatchErrorForString(helpers.ToPathLikeGorilla),
		"toPathLikeSinatra":      helpers.CatchErrorForString(helpers.ToPathLikeSinatra),
		"toLiteralForGo":         helpers.ToLiteralForGo,
		"convertTypeForGo":       helpers.ConvertTypeForGo,
		"convertTypeInJSONForGo": helpers.ConvertTypeInJSONForGo,
		"jsonTagForGo":           helpers.ConvertJSONTagForGo,
		"xormTagForGo":           helpers.ConvertXORMTagForGo,
		"convertArrayForGo":      helpers.ConvertArrayForGo,
		"toLiteralForJS":         helpers.ToLiteralForJS,
		"convertTypeForJS":       helpers.ConvertTypeForJS,
		"getKeyFromJSONPath":     helpers.GetKeyFromJSONPath,
		"snakeCase":              helpers.SnakeCase,
		"lowerSnakeCase":         helpers.LowerSnakeCase,<commit_msg>Export slice and in into template functions<commit_after>package jstmpl

import (
	"bytes"
	"go/format"
	"os"
	"text/template"

	"github.com/go-jstmpl/go-jstmpl/helpers"
	"github.com/go-jstmpl/go-jstmpl/types"
	"github.com/pkg/errors"
)

type Generator struct{}

func NewGenerator() *Generator {
	return &Generator{}
}

type FormatError struct {
	err error
}

func NewFormatError(e error) FormatError {
	return FormatError{
		err: errors.Wrap(e, "fail to format Go"),
	}
}

func (err FormatError) Error() string {
	return err.err.Error()
}

func (g *Generator) Process(model *types.Root, tmpl []byte, ext string) ([]byte, error) {
	out := bytes.NewBuffer([]byte{})
	t := template.Must(template.New("").Funcs(map[string]interface{}{
		"getEnv":                 os.Getenv,
		"add":                    helpers.Add,
		"sub":                    helpers.Sub,
		"slice":                  helpers.Slice,
		"in":                     helpers.In,
		"notLast":                helpers.NotLast,
		"joinTypes":              helpers.JoinTypes,
		"serialize":              helpers.Serialize,
		"toStringLiteral":        helpers.ToStringLiteral,
		"buildURLToken":          helpers.BuildURLToken,
		"toPathLikeGorilla":      helpers.CatchErrorForString(helpers.ToPathLikeGorilla),
		"toPathLikeSinatra":      helpers.CatchErrorForString(helpers.ToPathLikeSinatra),
		"toLiteralForGo":         helpers.ToLiteralForGo,
		"convertTypeForGo":       helpers.ConvertTypeForGo,
		"convertTypeInJSONForGo": helpers.ConvertTypeInJSONForGo,
		"jsonTagForGo":           helpers.ConvertJSONTagForGo,
		"xormTagForGo":           helpers.ConvertXORMTagForGo,
		"convertArrayForGo":      helpers.ConvertArrayForGo,
		"toLiteralForJS":         helpers.ToLiteralForJS,
		"convertTypeForJS":       helpers.ConvertTypeForJS,
		"getKeyFromJSONPath":     helpers.GetKeyFromJSONPath,
		"snakeCase":              helpers.SnakeCase,
		"lowerSnakeCase":         helpers.LowerSnakeCase,
{'fraction_non_alphanumeric': 0.12198355873773535, 'fraction_numerical': 0.0, 'mean_word_length': 3.172566371681416, 'pattern_counts': {'":': 44, '<': 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': '288019', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1254, 'n_words': 207}