temple

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package temple provides useful utilities for rendering go text/templates and html/templates with less boilerplate

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(templateString string, data interface{}) (*bytes.Buffer, error)

Render renders the template string into a buffer and includes some useful helper functions

Example
package main

import (
	"fmt"

	"github.com/brittonhayes/pkg/temple"
)

func main() {
	// Setup a template string and
	// interface for rendering
	templateString := "{{.Value}}"
	data := map[string]interface{}{
		"Value": "foo",
	}

	// Render the template
	output, err := temple.Render(templateString, data)
	if err != nil {
		return
	}

	// Print it out
	fmt.Println(output)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL