<commit_before>package tmpl

import (
    "github.com/mantyr/conf"
    "github.com/mantyr/debug"
    "html/template"
    "net/http"
    "encoding/json"
    "bytes"
    "log"
    "fmt"
    "io/ioutil"
)

func RenderHTML(data interface{}, address string) (r template.HTML, err error) {
    var v string
    v, err = RenderString(data, address)
    r = template.HTML(v)
    return
}

func RenderString(data interface{}, address string) (r string, err error) {
    var t *template.Template
    t, err = GetTemplate(conf.GetDirBin()+GetDir()+address)
    if err != nil {
        log.Printf("Bad template, %q\r\n", address)
        return
    }
    buf     := bytes.NewBuffer(nil)
    err      = t.Execute(buf, data)
    if err != nil {
        debug.Printf("Bad data in template, %q, %q\r\n", address, data)
    }

    var byt []byte
    byt, err = ioutil.ReadAll(buf)
    r        = string(byt)
    return
}

func Render(w http.ResponseWriter, data interface{}, address string) {
    t, err := GetTemplate(conf.GetDirBin()+GetDir()+address)<commit_msg>Fixed bug in Render address directory<commit_after>package tmpl

import (
    "github.com/mantyr/debug"
    "html/template"
    "net/http"
    "encoding/json"
    "bytes"
    "log"
    "fmt"
    "io/ioutil"
)

func RenderHTML(data interface{}, address string) (r template.HTML, err error) {
    var v string
    v, err = RenderString(data, address)
    r = template.HTML(v)
    return
}

func RenderString(data interface{}, address string) (r string, err error) {
    var t *template.Template
    t, err = GetTemplate(address)
    if err != nil {
        log.Printf("Bad template, %q\r\n", address)
        return
    }
    buf     := bytes.NewBuffer(nil)
    err      = t.Execute(buf, data)
    if err != nil {
        debug.Printf("Bad data in template, %q, %q\r\n", address, data)
    }

    var byt []byte
    byt, err = ioutil.ReadAll(buf)
    r        = string(byt)
    return
}

func Render(w http.ResponseWriter, data interface{}, address string) {
    t, err := GetTemplate(address)
{'fraction_non_alphanumeric': 0.1348700343305542, 'fraction_numerical': 0.0, 'mean_word_length': 2.6298932384341636, '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': '1015135', 'n_tokens_mistral': 697, 'n_tokens_neox': 703, 'n_words': 181}