Documentation
¶
Overview ¶
Package importer provides a common interface used to import Risor modules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Importer ¶
type Importer interface { // Import a module by name Import(ctx context.Context, name string) (*object.Module, error) }
Importer is an interface used to import Risor code modules
type LocalImporter ¶
type LocalImporter struct {
// contains filtered or unexported fields
}
func NewLocalImporter ¶
func NewLocalImporter(opts LocalImporterOptions) *LocalImporter
NewLocalImporter returns an Importer that can read Risor code modules from the local filesystem. Internally, loaded code is cached in memory. However, a new Module is created for each Import call. If the caller wants to reuse the same Module, it should be cached by the caller. It is safe to reuse the same local importer across multiple VMs and evaluations, because the cached code is immutable.
type LocalImporterOptions ¶
type LocalImporterOptions struct { // Global names that should be available when the module is compiled. GlobalNames []string // The directories to search for Risor modules. SourceDirs []string // Optional list of file extensions to try when locating a Risor module. Extensions []string }
LocalImporterOptions configure an Importer that can read from the local filesystem.
Click to show internal directories.
Click to hide internal directories.