Documentation ¶
Overview ¶
Package soyjs compiles Soy to javascript.
It fulfills the same interface as the javascript produced by the official Soy compiler and should work as a drop-in replacement. https://developers.google.com/closure/templates/docs/javascript_usage
It is presently alpha quality. See ../TODO for unimplemented features.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("file not found")
var Funcs = map[string]Func{ "isNonnull": {funcIsNonnull, []int{1}}, "length": {funcLength, []int{1}}, "keys": {builtinFunc("getMapKeys"), []int{1}}, "augmentMap": {builtinFunc("augmentMap"), []int{2}}, "round": {funcRound, []int{1, 2}}, "floor": {funcFloor, []int{1}}, "ceiling": {funcCeiling, []int{1}}, "min": {funcMin, []int{2}}, "max": {funcMax, []int{2}}, "randomInt": {funcRandomInt, []int{1}}, "strContains": {funcStrContains, []int{2}}, "hasData": {funcHasData, []int{0}}, "bidiGlobalDir": {funcBidiGlobalDir, []int{0}}, "bidiDirAttr": {funcBidiDirAttr, []int{0}}, "bidiStartEdge": {funcBidiStartEdge, []int{0}}, "bidiEndEdge": {funcBidiEndEdge, []int{0}}, }
Funcs contains the available soy functions. Callers may add custom functions to this map.
Functions ¶
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator provides an interface to a template registry capable of generating javascript to execute the embodied templates. The generated javascript requires lib/soyutils.js to already have been loaded.
func NewGenerator ¶
NewGenerator returns a new javascript generator capable of producing javascript for the templates contained in the given registry.
type JSWriter ¶
type JSWriter interface { // Write writes the given arguments into the generated javascript. It is // recommended to only pass strings and ast.Nodes to Write. Other types // are printed using their default string representation (fmt.Sprintf("%v")). Write(...interface{}) }
JSWriter is provided to functions to write to the generated javascript.