templates

package
v0.0.0-...-82e7740 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 6 Imported by: 4

README

util-templates GoDoc

template library for Go

Installation

go get gopkg.in/goyy/goyy.v0/util/templates

Documentation

Overview

Package templates implements data-driven templates for generating textual output.

Index

Examples

Constants

View Source
const (
	// EnIndex index
	EnIndex = "index"
	// EnShow show
	EnShow = "show"
	// EnEdit edit
	EnEdit = "edit"
	// EnAdd add
	EnAdd = "add"
)

Variables

View Source
var (
	// GetApis return to apis in static resources
	GetApis func() string
	// GetAssets return to assets in static resources
	GetAssets func() string
	// GetStatics return to statics in static resources
	GetStatics func() string
	// GetDevelopers return to developers in static resources
	GetDevelopers func() string
	// GetOperations return to operations in static resources
	GetOperations func() string
	// GetUploads return to uploads in static resources
	GetUploads func() string
)
View Source
var Html = html{funcMapHtml}

Html html funcMap

View Source
var Text = text{funcMapText}

Text text funcMap

Functions

func New

func New(name string) *template.Template

New allocates a new template with the given name.

func Process

func Process(tmpl string, data interface{}) (r string, err error)

Process compile template and output.

Example
data := map[string]interface{}{"name": "goyy", "updatedAt": "2014-03-19"}
out, _ := templates.Process(sql, data)
fmt.Println(out)
Output:

select * from demo where 1=1 and name like :name and updated_at < :updatedAt order by id

Types

This section is empty.

Jump to

Keyboard shortcuts

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