Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureLogging(level, internalLevel logging.Level, simple bool)
- func GetLogLevel() logging.Level
- func GetLoggingLevelFromString(level string) logging.Level
- func InitLogging() int
- func IsCode(code string) bool
- func IsRazor(code string) bool
- func SetLogLevel(level logging.Level)
- func TryGetLoggingLevelFromString(level string, defaultLevel logging.Level) (logging.Level, error)
- type FuncCategory
- type FuncInfo
- func (fi FuncInfo) Aliases() []string
- func (fi FuncInfo) Arguments() string
- func (fi FuncInfo) Description() string
- func (fi FuncInfo) Group() string
- func (fi FuncInfo) IsAlias() bool
- func (fi FuncInfo) Name() string
- func (fi FuncInfo) Result() string
- func (fi FuncInfo) Signature() string
- func (fi FuncInfo) String() (result string)
- type FuncOptions
- type FuncOptionsSet
- type Options
- type OptionsSet
- type String
- type Template
- func (t *Template) AddFunctions(funcs dictionary, group string, options FuncOptions) *Template
- func (t Template) GetNewContext(folder string, useCache bool) *Template
- func (t Template) IsCode(code string) bool
- func (t Template) IsRazor(code string) bool
- func (t Template) LeftDelim() string
- func (t Template) PrintFunctions(all, long, groupByCategory bool, filters ...string)
- func (t Template) PrintTemplates(all, long bool)
- func (t Template) ProcessContent(content, source string) (string, error)
- func (t Template) ProcessTemplate(template, sourceFolder, targetFolder string) (resultFile string, err error)
- func (t Template) ProcessTemplates(sourceFolder, targetFolder string, templates ...string) (resultFiles []string, err error)
- func (t Template) RazorDelim() string
- func (t Template) RightDelim() string
- func (t *Template) SetOption(option Options, value bool)
Constants ¶
const ( EnvAcceptNoValue = "GOTEMPLATE_NO_VALUE" EnvStrictErrorCheck = "GOTEMPLATE_STRICT_ERROR" EnvSubstitutes = "GOTEMPLATE_SUBSTITUTES" EnvDebug = "GOTEMPLATE_DEBUG" EnvExtensionPath = "GOTEMPLATE_PATH" // TODO: Deprecated, to remove in future version EnvDeprecatedAssign = "GOTEMPLATE_DEPRECATED_ASSIGN" )
Environment variables that could be defined to override default behaviors.
Variables ¶
var ( // ExtensionDepth the depth level of search of gotemplate extension from the current directory (default = 2). ExtensionDepth = 2 Print = utils.ColorPrint Printf = utils.ColorPrintf Println = utils.ColorPrintln ErrPrintf = utils.ColorErrorPrintf ErrPrintln = utils.ColorErrorPrintln ErrPrint = utils.ColorErrorPrint )
Common variables
var Log = logging.MustGetLogger(logger)
Log is the logger used to log message during template processing
Functions ¶
func ConfigureLogging ¶
ConfigureLogging allows configuration of the default logging level
func GetLogLevel ¶
GetLogLevel returns the current logging level for gotemplate
func GetLoggingLevelFromString ¶
GetLoggingLevelFromString converts a string into a logging level
func InitLogging ¶
func InitLogging() int
InitLogging allows configuration of the default logging level
func IsCode ¶
IsCode determines if the supplied code appears to have gotemplate code (using default delimiters).
func IsRazor ¶
IsRazor determines if the supplied code appears to have Razor code (using default delimiters).
func SetLogLevel ¶
SetLogLevel set the logging level for gotemplate
Types ¶
type FuncCategory ¶
type FuncCategory struct {
// contains filtered or unexported fields
}
FuncCategory represents a group of functions of the same group.
func (FuncCategory) Functions ¶
func (fc FuncCategory) Functions() []string
Functions returns the list of functions associated with the category.
func (FuncCategory) Name ¶
func (fc FuncCategory) Name() string
Name returns the name related to the entry.
type FuncInfo ¶
type FuncInfo struct {
// contains filtered or unexported fields
}
FuncInfo contains the information related to a function made available to go template.
func (FuncInfo) Arguments ¶
Arguments returns the list of arguments that must be supplied to the function.
func (FuncInfo) Description ¶
Description returns the description related to the entry.
type FuncOptions ¶
type FuncOptions map[FuncOptionsSet]interface{}
FuncOptions is a map of FuncOptionsSet that is used to associates help, aliases, arguments and groups to functions added to go template.
type FuncOptionsSet ¶
type FuncOptionsSet int8
FuncOptionsSet defines categories that could be used to define elaborated help context when adding functions to go template.
const ( // FuncHelp is used to associate help to functions added to go templates. FuncHelp FuncOptionsSet = iota // FuncArgs is used to associate arguments name to functions added to go templates. FuncArgs // FuncAliases is used to associate aliases to functions added to go templates. FuncAliases // FuncGroup is used to associate a group to functions added to go templates. FuncGroup )
type Options ¶
type Options int
Options defines the type that hold the various options & libraries that should be included
type OptionsSet ¶
OptionsSet represents the map of enabled options
func DefaultOptions ¶
func DefaultOptions() OptionsSet
DefaultOptions returns a OptionsSet with the first options turned on by default
type Template ¶
type Template struct { *template.Template TempFolder string // contains filtered or unexported fields }
Template let us extend the functionalities of base go template library.
func MustNewTemplate ¶
func MustNewTemplate(folder string, context interface{}, delimiters string, options OptionsSet, substitutes ...string) *Template
MustNewTemplate creates an Template object with default initialization. It panics if an error occurs.
func NewTemplate ¶
func NewTemplate(folder string, context interface{}, delimiters string, options OptionsSet, substitutes ...string) (result *Template, err error)
NewTemplate creates an Template object with default initialization.
func (*Template) AddFunctions ¶
func (t *Template) AddFunctions(funcs dictionary, group string, options FuncOptions) *Template
AddFunctions add functions to the template, but keep a detailled definition of the function added for helping purpose
func (Template) GetNewContext ¶
GetNewContext returns a distint context for each folder.
func (Template) PrintFunctions ¶
PrintFunctions outputs the list of functions available.
func (Template) PrintTemplates ¶
PrintTemplates output the list of templates available.
func (Template) ProcessContent ¶
ProcessContent loads and runs the file template.
func (Template) ProcessTemplate ¶
func (t Template) ProcessTemplate(template, sourceFolder, targetFolder string) (resultFile string, err error)
ProcessTemplate loads and runs the template if it is a file, otherwise, it simply process the content.
func (Template) ProcessTemplates ¶
func (t Template) ProcessTemplates(sourceFolder, targetFolder string, templates ...string) (resultFiles []string, err error)
ProcessTemplates loads and runs the file template or execute the content if it is not a file.
func (Template) RazorDelim ¶
RazorDelim returns the razor delimiter.
func (Template) RightDelim ¶
RightDelim returns the right delimiter.
Source Files ¶
- add_funcs.go
- extra_data.go
- extra_logging.go
- extra_math.go
- extra_net.go
- extra_os.go
- extra_runtime.go
- extra_sprig.go
- extra_utils.go
- func_category.go
- func_table.go
- generated_options.go
- math_base.go
- math_bits.go
- math_stats.go
- math_trig.go
- math_utilities.go
- options.go
- razor.go
- razor_expr.go
- razor_repl_assign.go
- razor_repl_autowrap.go
- razor_repl_expr.go
- razor_repl_literal.go
- slice.go
- template.go
- template_help.go
- template_process.go
- utils.go