templates

package
v1.0.0-...-8081051 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2014 License: BSD-3-Clause, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package templates includes the types and functionality for including templates in the gen package. The pattern is similar to that used in the image and database/sql packages, where the main templates package is imported, and specific template packages are included as image formats or sql drivers would be.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, ts TemplateSet)

Register allows template packages to make themselves known to a 'parent' package, usually in the init() func. Comparable to the approach taken by builtin image pacakge for registration of image types (eg image/png). Your program will do something like:

import (
	"github.com/clipperhouse/gen/templates"
	_ "github.com/clipperhouse/gen/templates/projection"
)

Types

type Template

type Template struct {
	Text            string
	RequiresNumeric bool
	// A comparable type is one that supports the == operator. Map keys must be comparable, for example.
	RequiresComparable bool
	// An ordered type is one where greater-than and less-than are supported
	RequiresOrdered bool
}

Template includes the text of a template as well as requirements for the types to which it can be applied.

type TemplateSet

type TemplateSet map[string]*Template

TemplateSet is a map of string names to Template.

func Get

func Get(name string) (TemplateSet, error)

GetTemplateSet attempts to a template set from the registered templates sets, by name Returns error if not found

func (TemplateSet) Contains

func (ts TemplateSet) Contains(name string) bool

Contains returns true if the TemplateSet includes a template of a given name.

func (TemplateSet) Get

func (ts TemplateSet) Get(name string) (t *template.Template, err error)

Get attempts to 1) locate a tempalte of that name and 2) parse the template Returns an error if the template is not found, and panics if the template can not be parsed (per text/template.Must)

func (TemplateSet) GetAllKeys

func (ts TemplateSet) GetAllKeys() (result []string)

GetAllKeys returns a slice of all 'exported' key names of templates in the TemplateSet

Directories

Path Synopsis
Package templates/container includes the type containers used by gen, such as Set and List.
Package templates/container includes the type containers used by gen, such as Set and List.
Package templates/projection includes the projection methods used by gen, such as GroupBy and Average.
Package templates/projection includes the projection methods used by gen, such as GroupBy and Average.
Package templates/standard includes the basic methods used by gen, including the plural type and methods such as Count and Where.
Package templates/standard includes the basic methods used by gen, including the plural type and methods such as Count and Where.

Jump to

Keyboard shortcuts

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