<commit_before>package venom

import (
	"encoding/json"
	"fmt"
	"strings"

	log "github.com/Sirupsen/logrus"
)

// Templater contains templating values on a testsuite
type Templater struct {
	values map[string]string
}

func newTemplater(values map[string]string) *Templater {
	return &Templater{values: values}
}

// Add add data to templater
func (tmpl *Templater) Add(prefix string, values map[string]string) {
	for k, v := range values {
		tmpl.values[prefix+"."+k] = v
	}
}

// Apply apply vars on string
func (tmpl *Templater) Apply(step TestStep) (TestStep, error) {

	log.Debugf("templater> before: %+v", step)

	s, err := json.Marshal(step)
	if err != nil {
		return nil, fmt.Errorf("templater> Error while marshaling: %s", err)
	}
	sb := string(s)

	for k, v := range tmpl.values {
		sb = strings.Replace(sb, "{{."+k+"}}", v, -1)
	}

	var t TestStep
	if err := json.Unmarshal([]byte(sb), &t); err != nil {
		return nil, fmt.Errorf("templater> Error while unmarshal: %s", err)
	}

	log.Debugf("templater> after: %+v", t)

	return t, nil
}<commit_msg>feat: expose Values of Templater<commit_after>package venom

import (
	"encoding/json"
	"fmt"
	"strings"

	log "github.com/Sirupsen/logrus"
)

// Templater contains templating values on a testsuite
type Templater struct {
	Values map[string]string
}

func newTemplater(values map[string]string) *Templater {
	return &Templater{Values: values}
}

// Add add data to templater
func (tmpl *Templater) Add(prefix string, values map[string]string) {
	for k, v := range values {
		tmpl.Values[prefix+"."+k] = v
	}
}

// Apply apply vars on string
func (tmpl *Templater) Apply(step TestStep) (TestStep, error) {

	log.Debugf("templater> before: %+v", step)

	s, err := json.Marshal(step)
	if err != nil {
		return nil, fmt.Errorf("templater> Error while marshaling: %s", err)
	}
	sb := string(s)

	for k, v := range tmpl.Values {
		sb = strings.Replace(sb, "{{."+k+"}}", v, -1)
	}

	var t TestStep
	if err := json.Unmarshal([]byte(sb), &t); err != nil {
		return nil, fmt.Errorf("templater> Error while unmarshal: %s", err)
	}

	log.Debugf("templater> after: %+v", t)

	return t, nil
}
{'fraction_non_alphanumeric': 0.15769770706598035, 'fraction_numerical': 0.0009358914365933552, 'mean_word_length': 4.201946472019465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6220765', 'n_tokens_mistral': 831, 'n_tokens_neox': 802, 'n_words': 228}