render

package
v0.0.0-...-02c76fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 19 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pipeline

func Pipeline(g *graph.Graph, id string, factory *Factory, top Values) executor.Pipeline

Pipeline generates a pipelined form of rendering

func Render

func Render(ctx context.Context, g *graph.Graph, top Values) (*graph.Graph, error)

Render a graph with the provided values

Types

type ErrBadTemplate

type ErrBadTemplate struct{ Err error }

ErrBadTemplate is returned by Render if the template string causes an error. It is likely to be returned in cases where a predicate function is rendered and does not result in a boolean value.

func (ErrBadTemplate) Error

func (e ErrBadTemplate) Error() string

type ErrUnresolvable

type ErrUnresolvable struct{}

ErrUnresolvable is returned by Render if the template string tries to resolve unaccesible node properties.

func (ErrUnresolvable) Error

func (ErrUnresolvable) Error() string

type Factory

type Factory struct {
	Graph     *graph.Graph
	DotValues map[string]*LazyValue
	Language  *extensions.LanguageExtension
}

Factory generates Renderers

func NewFactory

func NewFactory(ctx context.Context, g *graph.Graph) (*Factory, error)

NewFactory generates a new Render factory

func (*Factory) GetRenderer

func (f *Factory) GetRenderer(id string) (*Renderer, error)

GetRenderer returns a Factory for the specific graph node

type LazyValue

type LazyValue struct {
	// contains filtered or unexported fields
}

LazyValue wraps a ValueThunk in an interface and provides a way to cache the thunk evaluation.

func (*LazyValue) Value

func (v *LazyValue) Value() (resource.Value, bool, error)

Value returns the result of a ValueThunk, evaluating it if necessary

type PrepareThunk

type PrepareThunk struct {
	// prevent hashing thunks into a single value
	Data  []byte
	Thunk func(*Factory) (resource.Task, error) `hash:"ignore"`
}

PrepareThunk returns a possibly lazily evaluated preparer

func (*PrepareThunk) Apply

Apply allows thunk to implement resource.Task

func (*PrepareThunk) Check

Check allows thunk to implement resource.Task

type Renderer

type Renderer struct {
	Graph           func() *graph.Graph
	ID              string
	DotValue        resource.Value
	DotValuePresent bool

	Language *extensions.LanguageExtension
	// contains filtered or unexported fields
}

Renderer to be passed to preparers, which will render strings

func (*Renderer) GetID

func (r *Renderer) GetID() string

GetID returns the ID of this renderer

func (*Renderer) Render

func (r *Renderer) Render(name, src string) (string, error)

Render a string with text/template

func (*Renderer) Value

func (r *Renderer) Value() (value resource.Value, present bool)

Value of this renderer

type ValueThunk

type ValueThunk func() (resource.Value, bool, error)

ValueThunk lazily evaluates a param

type Values

type Values map[string]resource.Value

Values for rendering

Directories

Path Synopsis
Package extensions defines custom extensions to the go text templating language.
Package extensions defines custom extensions to the go text templating language.
platform
Package platform queries the underlying operating system
Package platform queries the underlying operating system

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL