Skip to content

Commit

Permalink
Expose the template lexical context
Browse files Browse the repository at this point in the history
  • Loading branch information
aisbergg committed Apr 22, 2022
1 parent f491f5e commit 9dd04d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions render/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

// Context provides the rendering context for a tag renderer.
type Context interface {
// Bindings returns the current lexical environment.
Bindings() map[string]interface{}
// Get retrieves the value of a variable from the current lexical environment.
Get(name string) interface{}
// Errorf creates a SourceError, that includes the source location.
Expand Down Expand Up @@ -75,6 +77,11 @@ func (c rendererContext) EvaluateString(source string) (out interface{}, err err
return expressions.EvaluateString(source, expressions.NewContext(c.ctx.bindings, c.ctx.config.Config.Config))
}

// Bindings returns the current lexical environment.
func (c rendererContext) Bindings() map[string]interface{} {
return c.ctx.bindings
}

// Get gets a variable value within an evaluation context.
func (c rendererContext) Get(name string) interface{} {
return c.ctx.bindings[name]
Expand Down

0 comments on commit 9dd04d0

Please sign in to comment.