mirror of
https://github.com/TECHNOFAB11/docsonnet.git
synced 2026-02-02 07:35:11 +01:00
feat: add extcode flag
This commit is contained in:
parent
629398bcac
commit
894f3a5b2a
3 changed files with 19 additions and 2 deletions
|
|
@ -11,7 +11,8 @@ import (
|
|||
)
|
||||
|
||||
type Opts struct {
|
||||
JPath []string
|
||||
JPath []string
|
||||
ExtCode map[string]string
|
||||
}
|
||||
|
||||
// Load extracts and transforms the docsonnet data in `filename`, returning the
|
||||
|
|
@ -51,6 +52,10 @@ func Extract(filename string, opts Opts) ([]byte, error) {
|
|||
// invoke load.libsonnet
|
||||
vm.ExtCode("main", fmt.Sprintf(`(import "%s")`, filename))
|
||||
|
||||
for k, v := range opts.ExtCode {
|
||||
vm.ExtCode(k, v)
|
||||
}
|
||||
|
||||
data, err := vm.EvaluateAnonymousSnippet("load.libsonnet", string(load))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue