Documentation
¶
Overview ¶
Package viewrender renders the supported view {} markup subset.
Index ¶
- Constants
- func ActionFormFields(source string) (map[string][]string, error)
- func ActionFormSchema(source string) (map[string][]ActionFormField, error)
- func ActionFormSchemaFromNodes(nodes []Node) (map[string][]ActionFormField, error)
- func Canonical(source string) (string, error)
- func ComponentReferences(source string) ([]string, error)
- func ComponentReferencesFromNodes(nodes []Node) []string
- func DOMEventSymbols() map[string]clientlang.ValueType
- func IslandExpressionFields(expr string) []string
- func IslandRefStatement(expr string) (string, bool)
- func ParamReferences(source string) ([]string, error)
- func ParamReferencesFromNodes(nodes []Node) []string
- func RenderNodesWithOptions(nodes []Node, components map[string]Component, data map[string]string, ...) (string, error)
- func RenderSPA(source string) (string, error)
- func RenderWithComponents(source string, components map[string]Component) (string, error)
- func RenderWithData(source string, components map[string]Component, data map[string]string) (string, error)
- func RenderWithOptions(source string, components map[string]Component, data map[string]string, ...) (string, error)
- func SupportedDirectiveNames() []string
- type ActionFormField
- type ActionInputField
- type Attr
- type AwaitBlock
- type CommandReference
- type Component
- type ComponentCall
- type ComponentCallUsage
- type ComponentIslandUsage
- type ComponentReference
- type ContractReference
- type ContractReferenceKind
- type Dependencies
- type Element
- type EventDirective
- type ForDirective
- type InlineScript
- type Node
- type Options
- type QueryReference
- type SSRCondReplacement
- type SSRListField
- type SSRListReplacement
- type SubscriptionReference
- type Text
Constants ¶
const ( ContractReferenceCommand = viewanalysis.ContractReferenceCommand ContractReferenceQuery = viewanalysis.ContractReferenceQuery )
Variables ¶
This section is empty.
Functions ¶
func ActionFormFields ¶
ActionFormFields returns direct literal HTML control names grouped by g:post action name. Component-hidden controls are intentionally not inferred in this first decoder slice.
func ActionFormSchema ¶
func ActionFormSchema(source string) (map[string][]ActionFormField, error)
ActionFormSchema returns direct literal HTML controls grouped by g:post action name. Duplicate field names are merged, and Required is true if any matching direct control is required.
func ActionFormSchemaFromNodes ¶
func ActionFormSchemaFromNodes(nodes []Node) (map[string][]ActionFormField, error)
ActionFormSchemaFromNodes returns direct literal HTML controls grouped by g:post action name from an already-parsed view fragment.
func ComponentReferences ¶
ComponentReferences returns unique component names directly referenced by a view markup fragment.
func ComponentReferencesFromNodes ¶
ComponentReferencesFromNodes returns unique component names directly referenced by an already-parsed view fragment.
func DOMEventSymbols ¶
func DOMEventSymbols() map[string]clientlang.ValueType
DOMEventSymbols returns the compiler-owned scalar DOM event scope exposed to g:on:* expressions.
func IslandExpressionFields ¶
IslandExpressionFields returns field references in a supported island event expression.
func IslandRefStatement ¶
IslandRefStatement reports whether expr is a safe DOM ref method call.
func ParamReferences ¶
func ParamReferencesFromNodes ¶
ParamReferencesFromNodes returns unique param("name") route-param references directly referenced by an already-parsed view fragment.
func RenderNodesWithOptions ¶
func RenderNodesWithOptions(nodes []Node, components map[string]Component, data map[string]string, options Options) (string, error)
RenderNodesWithOptions renders an already-parsed view fragment with component support, interpolation data, and page-scoped action endpoints.
func RenderWithComponents ¶
RenderWithComponents renders a view markup fragment with component support.
func RenderWithData ¶
func RenderWithData(source string, components map[string]Component, data map[string]string) (string, error)
RenderWithData renders a view markup fragment with component support and string interpolation data.
func RenderWithOptions ¶
func RenderWithOptions(source string, components map[string]Component, data map[string]string, options Options) (string, error)
RenderWithOptions renders a view markup fragment with component support, interpolation data, and page-scoped action endpoints.
func SupportedDirectiveNames ¶
func SupportedDirectiveNames() []string
SupportedDirectiveNames returns the sorted closed set of exact-name g: directives owned by the current view contract (excluding the g:on:* event family and the g:message:* rules, which are validated separately). It is the source of truth cross-checked against docs/language/stability.md.
Types ¶
type ActionFormField ¶
type ActionFormField struct {
Name string
File bool
MaxFiles int
MaxFileSize int64
AllowedFileTypes []string
Required bool
RequiredMessage string
MinLength int
MinLengthMessage string
MaxLength int
MaxLengthMessage string
Pattern string
PatternMessage string
}
ActionFormField describes one direct literal form field for a g:post action.
type ActionInputField ¶
ActionInputField describes Go action input metadata available while rendering literal controls inside a g:post form.
type AwaitBlock ¶
type AwaitBlock = viewmodel.AwaitBlock
type CommandReference ¶
type CommandReference = viewanalysis.CommandReference
func CommandReferences ¶
func CommandReferences(source string) ([]CommandReference, error)
CommandReferences returns package-qualified command references declared by g:command on direct form elements in a view fragment.
func CommandReferencesFromNodes ¶
func CommandReferencesFromNodes(nodes []Node) ([]CommandReference, error)
CommandReferencesFromNodes returns package-qualified command references declared by g:command on direct form elements in an already-parsed view fragment.
type ComponentCall ¶
type ComponentCall = viewmodel.ComponentCall
type ComponentCallUsage ¶
type ComponentCallUsage = viewanalysis.ComponentCallUsage
func ComponentCallUsages ¶
func ComponentCallUsages(source string) ([]ComponentCallUsage, error)
ComponentCallUsages returns component calls with optional g:island metadata.
func ComponentCallUsagesFromNodes ¶
func ComponentCallUsagesFromNodes(nodes []Node) ([]ComponentCallUsage, error)
ComponentCallUsagesFromNodes returns component calls with optional g:island metadata from an already-parsed view fragment.
type ComponentIslandUsage ¶
type ComponentIslandUsage = viewanalysis.ComponentIslandUsage
func ComponentIslandUsages ¶
func ComponentIslandUsages(source string) ([]ComponentIslandUsage, error)
ComponentIslandUsages returns component calls that explicitly set g:island.
func ComponentIslandUsagesFromNodes ¶
func ComponentIslandUsagesFromNodes(nodes []Node) ([]ComponentIslandUsage, error)
ComponentIslandUsagesFromNodes returns component calls that explicitly set g:island in an already-parsed view fragment.
type ComponentReference ¶
type ComponentReference = viewanalysis.ComponentReference
func ComponentReferenceSpans ¶
func ComponentReferenceSpans(source string) ([]ComponentReference, error)
ComponentReferenceSpans returns component calls directly referenced by a view markup fragment, preserving source offsets for diagnostics.
func ComponentReferenceSpansFromNodes ¶
func ComponentReferenceSpansFromNodes(nodes []Node) []ComponentReference
ComponentReferenceSpansFromNodes returns component calls from an already- parsed view fragment, preserving source offsets for diagnostics.
type ContractReference ¶
type ContractReference = viewanalysis.ContractReference
func ContractReferences ¶
func ContractReferences(source string) ([]ContractReference, error)
ContractReferences returns package-qualified command and query references declared by GOWDK view directives.
func ContractReferencesFromNodes ¶
func ContractReferencesFromNodes(nodes []Node) ([]ContractReference, error)
ContractReferencesFromNodes returns package-qualified command and query references declared by GOWDK view directives in an already-parsed view fragment.
type ContractReferenceKind ¶
type ContractReferenceKind = viewanalysis.ContractReferenceKind
type Dependencies ¶
type Dependencies = viewanalysis.Dependencies
func ViewDependencies ¶
func ViewDependencies(source string) (Dependencies, error)
ViewDependencies returns direct literal asset and style references from a view markup fragment. Interpolated and external URLs are not reported.
func ViewDependenciesFromNodes ¶
func ViewDependenciesFromNodes(nodes []Node) Dependencies
ViewDependenciesFromNodes returns direct literal asset and style references from an already-parsed view fragment.
type EventDirective ¶
type EventDirective struct {
Event string
Prevent bool
Stop bool
Once bool
Capture bool
DebounceMS int
ThrottleMS int
}
EventDirective is a parsed g:on:<event>[.<modifier>] directive.
func ParseEventDirective ¶
func ParseEventDirective(name string) (EventDirective, error)
ParseEventDirective validates and splits a g:on directive name.
func (EventDirective) RuntimeOptions ¶
func (directive EventDirective) RuntimeOptions() string
RuntimeOptions returns the compact modifier string emitted into HTML.
type ForDirective ¶
type ForDirective = viewparse.ForDirective
func ParseForDirective ¶
func ParseForDirective(source string) (ForDirective, error)
ParseForDirective parses a g:for value such as "item in Items" or "item, i in Items".
type InlineScript ¶
type InlineScript = viewmodel.InlineScript
type Options ¶
type Options struct {
Actions map[string]string
ActionInputFields map[string][]ActionInputField
Package string
Uses map[string]string
// Tainted names interpolation values that carry request-time,
// attacker-influenceable data (e.g. server {} fields). Tainted values are
// rejected in URL-bearing, event-handler, style, and srcdoc attributes the
// same way route params are, so they cannot smuggle a javascript:/data: URL
// past HTML-text escaping.
Tainted map[string]bool
RealtimeEventTypeNames map[string]string
QueryTypeNames map[string]string
// ServerListSink and ServerCondSink, when non-nil, receive the top-level
// g:for lists and g:if conditionals discovered while rendering a
// request-time page. The caller serializes them for the runtime region
// renderer.
ServerListSink *[]SSRListReplacement
ServerCondSink *[]SSRCondReplacement
}
Options configures view rendering.
type QueryReference ¶
type QueryReference = viewanalysis.QueryReference
func QueryReferences ¶
func QueryReferences(source string) ([]QueryReference, error)
QueryReferences returns package-qualified query references declared by g:query on direct HTML elements in a view fragment.
func QueryReferencesFromNodes ¶
func QueryReferencesFromNodes(nodes []Node) ([]QueryReference, error)
QueryReferencesFromNodes returns package-qualified query references declared by g:query on direct HTML elements in an already-parsed view fragment.
type SSRCondReplacement ¶
type SSRCondReplacement struct {
Placeholder string
SourcePath string
Negate bool
// Expr is a full bool expression for a top-level server g:if; when set the
// runtime evaluates it against the load data instead of SourcePath/Negate.
Expr string
Template string
Fields []SSRListField
Lists []SSRListReplacement
Conds []SSRCondReplacement
}
SSRCondReplacement is a build-time description of one server-rendered g:if conditional. Its branch renders only when SourcePath resolves to a truthy value (negated when Negate is set). The branch shares the enclosing container scope.
type SSRListField ¶
SSRListField is one per-render scalar substitution inside a region template.
type SSRListReplacement ¶
type SSRListReplacement struct {
Placeholder string
SourcePath string
ItemVar string
IndexVar string
RowTemplate string
Fields []SSRListField
Lists []SSRListReplacement
Conds []SSRCondReplacement
}
SSRListReplacement is a build-time description of one server-rendered g:for list. It is collected during a request-time page render and handed to the app generator, which serializes it for the runtime region renderer. The tree mirrors nesting: Lists and Conds describe g:for lists and g:if conditionals found inside RowTemplate.
type SubscriptionReference ¶
type SubscriptionReference = viewanalysis.SubscriptionReference
func SubscriptionReferences ¶
func SubscriptionReferences(source string) ([]SubscriptionReference, error)
SubscriptionReferences returns package-qualified presentation-event references declared by g:subscribe on query-owned elements.
func SubscriptionReferencesFromNodes ¶
func SubscriptionReferencesFromNodes(nodes []Node) ([]SubscriptionReference, error)
SubscriptionReferencesFromNodes returns package-qualified presentation-event references declared by g:subscribe on query-owned elements in an already-parsed view fragment.
Source Files
¶
- action_form_controls.go
- action_forms.go
- action_input_attrs.go
- api.go
- await.go
- bindings.go
- canonical.go
- component.go
- conditional.go
- directives.go
- element.go
- events.go
- helpers.go
- interpolate.go
- island_helpers.go
- island_statements.go
- node_loop.go
- output.go
- param_references.go
- patterns.go
- render.go
- render_context.go
- safety.go
- server_list.go
- view.go