<commit_before>package template

import (
	"encoding/json"
	"fmt"
	"io"
	"strings"
	"time"
	"unicode"
	"unicode/utf8"

	"github.com/aymerick/raymond"
	"github.com/drone/drone-go/drone"
)

func init() {
	raymond.RegisterHelpers(funcs)
}

// Render parses and executes a template, returning the results
// in string format.
func Render(template string, playload *drone.Payload) (string, error) {
	return raymond.Render(template, normalize(playload))<commit_msg>Integrated optional remote templates<commit_after>package template

import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"strings"
	"time"
	"unicode"
	"unicode/utf8"

	"github.com/aymerick/raymond"
	"github.com/drone/drone-go/drone"
)

func init() {
	raymond.RegisterHelpers(funcs)
}

// Render parses and executes a template, returning the results
// in string format.
func Render(template string, playload *drone.Payload) (string, error) {
	if strings.HasPrefix(template, "http") {
		resp, err := http.Get(template)

		if err != nil {
			return "", fmt.Errorf("Failed to fetch remote template: %s", err)
		}

		defer resp.Body.Close()

		content, err := ioutil.ReadAll(resp.Body)

		if err != nil {
			return "", fmt.Errorf("Failed to read remote template: %s", err)
		}

		template = string(content)
	}

	return raymond.Render(template, normalize(playload))
{'fraction_non_alphanumeric': 0.1401938851603281, 'fraction_numerical': 0.0014914243102162564, 'mean_word_length': 4.368, 'pattern_counts': {'":': 0, '<': 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': '1836099', 'n_tokens_mistral': 501, 'n_tokens_neox': 478, 'n_words': 114}