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 FSImporter ¶ added in v1.8.0
type FSImporter struct {
// contains filtered or unexported fields
}
FSImporter is an Importer that can read Risor code modules from a filesystem implementing the `fs.FS` interface.
func NewFSImporter ¶ added in v1.8.0
func NewFSImporter(opts FSImporterOptions) *FSImporter
NewFSImporter returns an Importer that can read Risor code modules from a filesystem implementing the `fs.FS` interface.
type FSImporterOptions ¶ added in v1.8.0
type FSImporterOptions struct {
// Global names that should be available when the module is compiled.
GlobalNames []string
// The filesystem to search for Risor modules.
SourceFS fs.FS
// Optional list of file extensions to try when locating a Risor module.
Extensions []string
}
FSImporterOptions configure an Importer that can read from a filesystem implementing the `fs.FS` interface.
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
}
LocalImporter is an Importer that can read Risor code modules from the local filesystem.
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 directory to search for Risor modules.
SourceDir 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.