Runtime

Runtime

alias

func alias(name string, function string, source interface{}, args
...interface{}) string
Defines an alias (go template function) using the function (exec, run,
include, template). Executed in the context of the caller.

aliases

func aliases() []string
Returns the list of all functions that are simply an alias of another
function.

allFunctions

func allFunctions() []string
Returns the list of all available functions.

assert

func assert(test interface{}, message ...interface{}) string
Raises a formated error if the test condition is false.

Aliases

  • assertion

assertWarning

func assertWarning(test interface{}, message ...interface{}) string
Issues a formated warning if the test condition is false.

Aliases

  • assertw

categories

func categories() []template.FuncCategory
Returns all functions group by categories.

The returned value has the following properties:
    Name string
    Functions []string

completeExamples

func completeExamples() string
Complete the examples that are not fully generated.

current

func current() string
Returns the current folder (like pwd, but returns the folder of the
currently running folder).

ellipsis

func ellipsis(function string, args ...interface{}) interface{}
Returns the result of the function by expanding its last argument that
must be an array into values. It's like calling function(arg1, arg2,
otherArgs...).

exec

func exec(command interface{}, args ...interface{}) interface{}
Returns the result of the shell command as structured data (as string
if no other conversion is possible).

Aliases

  • execute

exit

func exit(exitValue int) int
Exits the current program execution.

func

func func(name string, function string, source interface{}, config
interface{}) string
Defines a function with the current context using the function (exec,
run, include, template). Executed in the context of the caller.

function

func function(name string) *template.FuncInfo
Returns the information relative to a specific function.

The returned value has the following properties:
    Name string
    Description string
    Signature string
    Group string
    Aliases []string
    Arguments string
    Result string

functions

func functions() []string
Returns the list of all available functions (excluding aliases).

getAttributes

func getAttributes(arg1 interface{}) string
List all attributes accessible from the supplied object.

Aliases

  • attr
  • attributes

getMethods

func getMethods(arg1 interface{}) string
List all methods signatures accessible from the supplied object.

Aliases

  • methods

getSignature

func getSignature(arg1 interface{}) string
List all attributes and methods signatures accessible from the
supplied object.

Aliases

  • sign
  • signature

include

func include(source interface{}, context ...interface{}) interface{}
Runs the given template code and returns the output.

Template code can be specified as:
- A file path
- The name of a defined template
- A string containing template code

This is similar to what the template action does but it allows you to
capture its output in a variable.

Aliases

  • eval

Examples

Razor:    Raw code: @(include "@(2+2)")
Template: Raw code: {{ include "@(2+2)" }}
Result:   Raw code: 4
Razor:    @--define("my-template")
          @--(2+2)
          @--end
          Defined template: @(include "my-template")
Template: {{- define "my-template" -}}
          {{- add 2 2 -}}
          {{- end -}}
          Defined template: {{ include "my-template" }}
Result:   Defined template: 4

localAlias

func localAlias(name string, function string, source interface{}, args
...interface{}) string
Defines an alias (go template function) using the function (exec, run,
include, template). Executed in the context of the function it maps
to.

raise

func raise(args ...interface{}) string
Raise a formated error.

Aliases

  • raiseError

run

func run(command interface{}, args ...interface{}) interface{}
Returns the result of the shell command as string.

substitute

func substitute(content string) string
Applies the supplied regex substitute specified on the command line on
the supplied string (see --substitute).

templateNames

func templateNames() []string
Returns the list of available templates names.

templates

func templates() []*template.Template
Returns the list of available templates.

userContext

func userContext() interface{}
Returns the user context (i.e. all global variables except the
injected constant).

Aliases

  • c
  • context