layouts

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeString = "string"
	TypeNumber = "number"
	TypeBool   = "bool"
	TypeImage  = "image"
	TypeVideo  = "video"
	TypeColor  = "color"
)
View Source
const (
	FormatMarkdown = "markdown"
	FormatHTML     = "html"
	FormatPlain    = "plain"
)

Variables

This section is empty.

Functions

func IsKnownFormat

func IsKnownFormat(f string) bool

func IsKnownType

func IsKnownType(d string) bool

func Render

func Render(l *Layout, vars Vars, renderCtx *RenderContext) ([]byte, error)

Render renders the layout l.

func RequiresUpload

func RequiresUpload(varType string) bool

func Validate

func Validate(layout *Layout) error

Validate layout and return any errors encountered.

Types

type Layout

type Layout struct {
	Name        string     `hcl:"name,label" json:"name"`
	DisplayName string     `hcl:"displayName" json:"displayName"`
	File        string     `hcl:"file,optional" json:"file,omitempty"`
	Content     string     `hcl:"content,optional" json:"content,omitempty"`
	Description string     `hcl:"description,optional" json:"description,omitempty"`
	Variables   []Variable `hcl:"variable,block" json:"variables"`
	PreviewIcon string     `hcl:"previewIcon" json:"previewIcon"`
	// contains filtered or unexported fields
}

Layout defines a new slide layout.

func ParseFile

func ParseFile(fpath string) (*Layout, error)

ParseFile parses a layout from fpath. All files referenced in the layout are relative to the parent directory of fpath.

func (*Layout) FilePath

func (l *Layout) FilePath(fpath string) string

FilePath returns the absolute file path to fpath.

func (*Layout) ParentDir

func (l *Layout) ParentDir() string

ParentDir returns the directory that contains the layout definition. This directory must be used as the root for all static file assets referenced by the layout.

func (*Layout) Var

func (l *Layout) Var(name string) *Variable

Var returns the definition for the variable name.

type NoopStore

type NoopStore struct{}

func (*NoopStore) Get

func (*NoopStore) ListNames

func (*NoopStore) ListNames(context.Context) ([]string, error)

type RenderContext

type RenderContext struct {
	Preview  bool
	Embedded bool
}

type Store

type Store interface {
	// Get returnes the parsed layout by name.
	Get(ctx context.Context, name string) (*Layout, error)

	// ListNames returns a list of layout names.
	ListNames(ctx context.Context) ([]string, error)
}

func NewFileStore

func NewFileStore(ctx context.Context, dirs []string) (Store, error)

NewFileStore returns a new layout store that loads and persists layouts in dir.

type Variable

type Variable struct {
	Name        string   `hcl:"name,label" json:"name"`
	Type        string   `hcl:"type" json:"type"`
	Description string   `hcl:"description,optional" json:"description,omitempty"`
	Required    bool     `hcl:"required,optional" json:"required,omitempty"`
	Format      string   `hcl:"format,optional" json:"format,omitempty"`
	Multiline   bool     `hcl:"multiline,optional" json:"multiline,omitempty"`
	DisplayName string   `hcl:"displayName,optional" json:"displayName,omitempty"`
	Choices     []string `hcl:"choices,optional" json:"choices,omitempty"`
	Multi       bool     `hcl:"multi,optional" json:"multi,omitempty"`
}

Variable defines an input variable for a template layout.

type Vars

type Vars map[string]interface{}

Vars holds layout variables.

Jump to

Keyboard shortcuts

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