Documentation ¶
Index ¶
- Variables
- func AddDispatcers(ast js.INode, globalScope *js.Scope, contextVariables *cmn.IndexedSet, ...)
- func CallExpr(name string, args ...js.IExpr) *js.CallExpr
- func GetContextFunctionBodyExpr(contextAst *js.AST, funcRef *js.Var) *js.BlockStmt
- func GroupCommaExpr(list ...js.IExpr) js.GroupExpr
- func HasSideEffect(ast js.INode, contextAst *js.AST) (bool, string)
- func IntegerExpr(value int) js.LiteralExpr
- func Interpolate(text string, sequence *sht.Sequence) (string, map[string]*Interpolation, error)
- func IsBinaryAssignmentOperator(tokenType js.TokenType) bool
- func IsContextLetOrVarDecl(variable *js.Var, contextAst *js.AST) (bool, *js.BindingElement)
- func IsContextSingleLetOrVarReference(ast *js.AST, contextAst *js.AST) (bool, *js.Var)
- func IsDeclaredOnScope(expr *js.Var, scope *js.Scope) (bool, *js.Var)
- func StringExpr(value string) js.LiteralExpr
- func WalkScoped(v IVisitorScoped, n js.INode, stack *WalkScopeStack)
- type ExpressionsParser
- type IVisitorScoped
- type IVisitorScopedFunc
- type Interpolation
- type Javascript
- type JsNodeReference
- type NodeComponentParams
- type VisitorEnterFunc
- type WalkScope
- type WalkScopeStack
Constants ¶
This section is empty.
Variables ¶
var ClientInvalidParamsAndRefs = sht.CreateBoolMap([]string{
"STX", "$", "push", "watch", "tick",
"OnMount", "BeforeUpdate", "AfterUpdate", "BeforeRender", "AfterRender", "OnDestroy", "OnConnect", "OnDisconnect",
"OnError", "OnEvent",
})
ClientInvalidParamsAndRefs reserved variable names, cannot be used in parameters or references. The prefix "_$" is also not allowed.
var ClientLifeCycleMap = map[string]string{
"OnMount": "a",
"BeforeUpdate": "b",
"AfterUpdate": "c",
"BeforeRender": "d",
"AfterRender": "e",
"OnDestroy": "f",
"OnConnect": "g",
"OnDisconnect": "h",
"OnEvent": "i",
"OnError": "j",
}
ClientLifeCycleMap The methods and attributes that are part of the structure of a JS component
var HtmlEventsPush = sht.CreateBoolMap([]string{
"onblur", "onchange", "oncontextmenu", "onfocus", "oninput", "oninvalid", "onreset", "onsearch", "onselect", "onsubmit",
"onclick", "ondblclick", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onwheel",
})
HtmlEventsPush list of events that are enabled by default to push to server
Functions ¶
func AddDispatcers ¶
func AddDispatcers(ast js.INode, globalScope *js.Scope, contextVariables *cmn.IndexedSet, stack *WalkScopeStack)
func HasSideEffect ¶
HasSideEffect checks if the Expression has a side effect. Returns on first side effect Expression found.
func IntegerExpr ¶
func IntegerExpr(value int) js.LiteralExpr
func Interpolate ¶
Interpolate processa as interpolações javascript em um texto
JAVASCRIPT INTERPOLATION ( ${value} or #{value} )
<element attribute="${return value}"> <element attribute="xpto ${escape safe}"> <element attribute="xpto #{escape unsafe}"> <element attribute="#{escape unsafe}"> <element>${escape safe}</element> <element>#{escape unsafe}</element> #{serverExpressionUnescaped}
@TODO: Filters/Pipe. Ex. ${ myValue | upperCase}
newText, watches, err = Interpolate('Hello ${name}!'); newText == "Hello _j$_i15151ffacb" interpolations == {"_j$_i15151ffacb": {Expression: "name", isScape: true}} exp.Exec({name:'Syntax'}).String() == "Hello Syntax!"
func IsBinaryAssignmentOperator ¶
IsBinaryAssignmentOperator check if is a JavaScript Assignment Operators
func IsContextLetOrVarDecl ¶
IsContextLetOrVarDecl checks if the variable is a "var" or "let" declaration in the global context
func IsContextSingleLetOrVarReference ¶
IsContextSingleLetOrVarReference checks if the given expression refers to a single variable defined in the global scope
func IsDeclaredOnScope ¶
IsDeclaredOnScope check if this Expression is declared on specified scope
func StringExpr ¶
func StringExpr(value string) js.LiteralExpr
func WalkScoped ¶
func WalkScoped(v IVisitorScoped, n js.INode, stack *WalkScopeStack)
WalkScoped traverses an AST in depth-first order
Types ¶
type ExpressionsParser ¶
type ExpressionsParser struct { Node *sht.Node Sequence *sht.Sequence ContextAst *js.AST ContextAstScope *js.Scope ContextVariables *cmn.IndexedSet Elements *cmn.IndexedSet AttributeNames *cmn.IndexedSet Expressions *cmn.IndexedSet EventNames *cmn.IndexedSet Events *cmn.IndexedSet Writers *cmn.IndexedSet Watchers *cmn.IndexedSet NodeIdentifierFunc func(node *sht.Node) string }
func (*ExpressionsParser) Parse ¶
func (p *ExpressionsParser) Parse() error
Parse Faz o processamento e validação de todas as expressões existente no código HTML do template
Check for expressions (${value} or #{value})
Text escaping <element>${escape safe}</element> <element>#{escape unsafe}</element>
Attributes escaping <element attr="text ${escape safe}"> <element attr="text #{escape unsafe}"> <element attr="${return value}"> <element attr="#{escape unsafe}">
Bindings <input value="${value}"></input>
type IVisitorScoped ¶
type IVisitorScoped interface { Enter(n js.INode, scope *WalkScopeStack) IVisitorScoped Exit(n js.INode) }
IVisitorScoped represents the AST Visitor Each INode encountered by `Walk` is passed to `Enter`, children nodes will be ignored if the returned IVisitor is nil `Exit` is called upon the exit of a node
type IVisitorScopedFunc ¶
type IVisitorScopedFunc func(node js.INode, scope *WalkScopeStack) (visitChildren bool)
IVisitorScopedFunc use function as AST Visitor
func (IVisitorScopedFunc) Enter ¶
func (f IVisitorScopedFunc) Enter(node js.INode, scope *WalkScopeStack) IVisitorScoped
func (IVisitorScopedFunc) Exit ¶
func (f IVisitorScopedFunc) Exit(node js.INode)
type Interpolation ¶
func (*Interpolation) Debug ¶
func (i *Interpolation) Debug() string
type Javascript ¶
type Javascript struct { Content string ComponentParams []cmn.ComponentParam }
Javascript Represents a resource needed by a component
type JsNodeReference ¶
func ParseReferences ¶
func ParseReferences(node *sht.Node) ([]*JsNodeReference, error)
ParseReferences handles references made available to JS (<element ref="myJsVariable">)
type NodeComponentParams ¶
type NodeComponentParams struct { ServerParams []cmn.ComponentParam // server params ClientParams []cmn.ComponentParam // javascript params AttrsToRemove []*sht.Attribute ServerParamsByName map[string]*cmn.ComponentParam ClientParamsByName map[string]*cmn.ComponentParam }
func ParseComponentParams ¶
func ParseComponentParams(node *sht.Node) (*NodeComponentParams, error)
ParseComponentParams Processes the parameters of a component
Qualquer componente
type VisitorEnterFunc ¶
VisitorEnterFunc use function as AST Visitor
Each INode encountered by `walk` is passed to func, children nodes will be ignored if return false
func (VisitorEnterFunc) Exit ¶
func (f VisitorEnterFunc) Exit(node js.INode)
type WalkScopeStack ¶
type WalkScopeStack struct {
// contains filtered or unexported fields
}
func (*WalkScopeStack) Pop ¶
func (r *WalkScopeStack) Pop()
func (*WalkScopeStack) Push ¶
func (r *WalkScopeStack) Push(scope *WalkScope)