<commit_before>// Package templates provides abstractions for work
// with standard Go template engine.
package templates

import (
	"html/template"
	"net/http"

	"github.com/anonx/sunplate/config"
)

var (
	baseTemplate, templateName, delimLeft, delimRight string

	// Funcs are added to the template's function map.
	// Functions are expected to return just 1 argument or
	// 2 in case the second one is of error type.
	Funcs template.FuncMap
)

// Templates is a controller that provides support of HTML result
// rendering to your application.
// Use SetTemplatePaths to register templates and
// call c.RenderTemplate from your action to render some.
type Templates struct {
	// Context is used for passing variables to templates.
	Context map[string]interface{}

	// Status is a status code that will be returned when rendering.
	Status int
}

// Before initializes Context that will be passed to template.
func (c *Templates) Before() http.Handler {
	c.Context = map[string]interface{}{}
	return nil
}

// RenderTemplate is an action that gets a path to template
// and renders it using data from Context.
func (c *Templates) RenderTemplate(templatePath string) http.Handler {
	return &Handler{
		context:  c.Context,
		template: templatePath,
	}
}

// RenderNotFound is an action that renders Error 404 page.<commit_msg>Added RenderError method to templates controller<commit_after>// Package templates provides abstractions for work
// with standard Go template engine.
package templates

import (
	"html/template"
	"net/http"

	"github.com/anonx/sunplate/config"
)

var (
	baseTemplate, templateName, delimLeft, delimRight string

	// Funcs are added to the template's function map.
	// Functions are expected to return just 1 argument or
	// 2 in case the second one is of error type.
	Funcs template.FuncMap
)

// Templates is a controller that provides support of HTML result
// rendering to your application.
// Use SetTemplatePaths to register templates and
// call c.RenderTemplate from your action to render some.
type Templates struct {
	// Context is used for passing variables to templates.
	Context map[string]interface{}

	// Status is a status code that will be returned when rendering.
	Status int
}

// Before initializes Context that will be passed to template.
func (c *Templates) Before() http.Handler {
	c.Context = map[string]interface{}{}
	return nil
}

// RenderTemplate is an action that gets a path to template
// and renders it using data from Context.
func (c *Templates) RenderTemplate(templatePath string) http.Handler {
	return &Handler{
		context:  c.Context,
		template: templatePath,
	}
}

// RenderError is an action that renders Error 500 page.
func (c *Templates) RenderError() http.Handler {
	c.Status = http.StatusInternalServerError
	return c.RenderTemplate("Errors/InternalError.html")
}

// RenderNotFound is an action that renders Error 404 page.
{'fraction_non_alphanumeric': 0.0783569209527097, 'fraction_numerical': 0.0044874007594062825, 'mean_word_length': 3.996551724137931, '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': '345459', 'n_tokens_mistral': 812, 'n_tokens_neox': 782, 'n_words': 348}