template

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package template provides the functionality to render html pages based on the html/templates provided by go

Index

Constants

View Source
const (
	// HTML enum denoting html file
	HTML fileType = iota
	// TEXT enum denoting text file
	TEXT
	// CSV enum denoting csv file
	CSV
	// FILE enum denoting other file types
	FILE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// Content holds the file data in slice of bytes
	Content []byte
	// ContentType holds the info about the file type
	ContentType string
}

File contains the information about a File and provides functionality to render those files

type Template

type Template struct {
	// Directory denotes the path to the file
	Directory string
	// File denotes the file name
	File string
	// Data has the information that template need to render the file
	Data interface{}
	// Type denotes the file type which is an integer
	Type fileType
}

Template contains the info about the file and implements a renderer to render the file

func (*Template) ContentType

func (t *Template) ContentType() string

ContentType returns the content type associated with the template's file type.

func (*Template) Render

func (t *Template) Render() ([]byte, error)

Render compiles and executes the template, returning the rendered content. It automatically determines the template location and content type.

Jump to

Keyboard shortcuts

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