run

package
Version: v1.0.0-...-5ac96c6 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package run provide the logic for generating code for the gentmpl tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// Do not cache the templates.
	// A new template will be created on every page.Execute.
	NoCache bool

	// Do not format the generated code with go/format.
	NoGoFormat bool

	// Package name used in the generated code.
	PackageName string

	// Asset manager to use. Possible values:
	// - none (default)
	// - go-bindata
	AssetManager types.AssetManager

	// Use text/template instead of html/template.
	TextTemplate bool

	// Name of the template.FuncMap variable used in template creation.
	// The variable must be defined in another file of the same package
	// (ex: "templates/func-map.go").
	// If empty, no funcMap will be used.
	FuncMap string

	// Name of the PageEnum type definition.
	PageEnumType string

	// Strings used as prefix and suffix in the PageEnum constants.
	// Example:  page "CreateUser", prefix="Page", suffix="" -> PageCreateUser
	PageEnumPrefix string
	PageEnumSuffix string

	// Name of the TemplateEnum type definition.
	TemplateEnumType string

	// Base folder of the templates files.
	TemplateBaseDir string

	// Mapping from template name to items used to create the template.
	// Each item can be a:
	// - file path to parse in the template creation.
	// - name of another template to include in the current template.
	Templates map[string][]string

	// Mapping from page name to template name and base values used to render
	// the page.
	Pages map[string]struct {
		Template string
		Base     string
	}
}

Context contains the parameters that manage the code generation.

The default values of the struct are so that no NewContext() func is needed to initialize the struct.

func (*Context) Check

func (ctx *Context) Check() error

Check check for errors in the Context's parameters.

func (*Context) WriteConfig

func (ctx *Context) WriteConfig(w io.Writer) error

WriteConfig prints the current Context to writer using a TOML file format. The file has comments describing each parameter of the configuration.

func (*Context) WritePackage

func (ctx *Context) WritePackage(w io.Writer) error

WritePackage prints the generated package to writer.

Directories

Path Synopsis
Package collection implements collection types as UniqueStrings
Package collection implements collection types as UniqueStrings
Package lib implements some library functions used by gentmpl utility.
Package lib implements some library functions used by gentmpl utility.
Package types implements types used in the gentmpl utility
Package types implements types used in the gentmpl utility

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL