Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // EnableGlobalScope creates global variables if it's set to true. // If not, global variables in Tengo code will be transpiled as local // variables in Lua. EnableGlobalScope bool // Indent string is added whenever the block level increases. Indent string }
Options represents a set of options for Transpiler.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions creates a default option for Transpiler.
type Transpiler ¶
type Transpiler struct {
// contains filtered or unexported fields
}
Transpiler converts Tengo source code into Lua code.
Example ¶
package main import ( "fmt" "github.com/d5/tengo2lua" ) func main() { src := []byte(` each := func(x, f) { for k, v in x { f(k, v) } } sum := 0 each([1, 2, 3], func(i, v) { sum += v }) `) t := tengo2lua.NewTranspiler(src, nil) dst, err := t.Convert() if err != nil { panic(err) } fmt.Println(string(dst)) }
Output:
func NewTranspiler ¶
func NewTranspiler(src []byte, opts *Options) *Transpiler
NewTranspiler creates a new Transpiler.
func (*Transpiler) Convert ¶
func (t *Transpiler) Convert() (output string, err error)
Convert converts the input Tengo source code.
Click to show internal directories.
Click to hide internal directories.