{"modulePath":"github.com/stackpointcloud/packer","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package interpolate\n\n## Variables\n\n```go\nvar FuncGens = map[string]FuncGenerator{\n\t\"build_name\":   funcGenBuildName,\n\t\"build_type\":   funcGenBuildType,\n\t\"env\":          funcGenEnv,\n\t\"isotime\":      funcGenIsotime,\n\t\"pwd\":          funcGenPwd,\n\t\"template_dir\": funcGenTemplateDir,\n\t\"timestamp\":    funcGenTimestamp,\n\t\"uuid\":         funcGenUuid,\n\t\"user\":         funcGenUser,\n\n\t\"upper\": funcGenPrimitive(strings.ToUpper),\n\t\"lower\": funcGenPrimitive(strings.ToLower),\n}\n```\nFuncs are the interpolation funcs that are available within interpolations.\n\n```go\nvar InitTime time.Time\n```\nInitTime is the UTC time when this package was initialized. It is used as the timestamp for all configuration templates so that they match for a single build.\n\n## Functions\n\n```go\nfunc Funcs(ctx *Context) template.FuncMap\n```\nFuncs returns the functions that can be used for interpolation given a context.\n\n```go\nfunc Render(v string, ctx *Context) (string, error)\n```\nRender is shorthand for constructing an I and calling Render.\n\n```go\nfunc RenderInterface(v interface{}, ctx *Context) (interface{}, error)\n```\nRenderInterface renders any value and returns the resulting value.\n\n```go\nfunc RenderMap(v interface{}, ctx *Context, f *RenderFilter) (map[string]interface{}, error)\n```\nRenderMap renders all the strings in the given interface. The interface must decode into a map\\[string]interface{}, but is left as an interface{} type to ease backwards compatibility with the way arguments are passed around in Packer.\n\n```go\nfunc Validate(v string, ctx *Context) error\n```\nValidate is shorthand for constructing an I and calling Validate.\n\n```go\nfunc ValidateInterface(v interface{}, ctx *Context) error\n```\nValidateInterface renders any value and returns the resulting value.\n\n## Types\n\n```go\ntype Context struct {\n\t// Data is the data for the template that is available\n\tData interface{}\n\n\t// Funcs are extra functions available in the template\n\tFuncs map[string]interface{}\n\n\t// UserVariables is the mapping of user variables that the\n\t// \"user\" function reads from.\n\tUserVariables map[string]string\n\n\t// EnableEnv enables the env function\n\tEnableEnv bool\n\n\t// All the fields below are used for built-in functions.\n\t//\n\t// BuildName and BuildType are the name and type, respectively,\n\t// of the builder being used.\n\t//\n\t// TemplatePath is the path to the template that this is being\n\t// rendered within.\n\tBuildName    string\n\tBuildType    string\n\tTemplatePath string\n}\n```\nContext is the context that an interpolation is done in. This defines things such as available variables.\n\n```go\ntype FuncGenerator func(*Context) interface{}\n```\nFuncGenerator is a function that given a context generates a template function for the template.\n\n```go\ntype I struct {\n\tValue string\n}\n```\nI stands for \"interpolation\" and is the main interpolation struct in order to render values.\n\n```go\nfunc (i *I) Render(ctx *Context) (string, error)\n```\nRender renders the interpolation with the given context.\n\n```go\nfunc (i *I) Validate(ctx *Context) error\n```\nValidate validates that the template is syntactically valid.\n\n```go\ntype RenderFilter struct {\n\tInclude []string\n\tExclude []string\n\t// contains filtered or unexported fields\n}\n```\nRenderFilter is an option for filtering what gets rendered and doesn't within an interface.\n\n","path":"github.com/stackpointcloud/packer/template/interpolate","name":"interpolate","synopsis":"","isRedistributable":true}
