We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a context.yml file contains: ARRAY: ['elem1', 'elem2', 'elem3'] template.conf file contains: array: {{ ARRAY }}
ARRAY: ['elem1', 'elem2', 'elem3']
array: {{ ARRAY }}
I did templating and expected output is: array: ['elem1', 'elem2', 'elem3'] and actual output is: array: <[]interface {} Value>
array: ['elem1', 'elem2', 'elem3']
array: <[]interface {} Value>
code snippet:
package main import ( "fmt" "github.com/flosch/pongo2/v6" "gopkg.in/yaml.v2" "io/ioutil" "os" ) func main() { //write ARRAY: ['elem1', 'elem2', 'elem3'] to context.yml os.WriteFile("context.yml", []byte("ARRAY: ['elem1', 'elem2', 'elem3']"), 0644) //write array: {{ ARRAY }} to template.conf os.WriteFile("template.conf", []byte("array: {{ ARRAY }}"), 0644) readByte, err := readFile("template.conf") if err != nil { return } context := pongo2.Context{} contextFile, err := os.Open("context.yml") if err != nil { return } out := make(map[string]interface{}) if err := yaml.NewDecoder(contextFile).Decode(out); err != nil { return } fmt.Println("yml decode: ", out) contextFile.Seek(0, 0) if err := yaml.NewDecoder(contextFile).Decode(&context); err != nil { return } temp, err := pongo2.FromBytes(readByte) if err != nil { return } output, err := temp.Execute(context) if err != nil { return } fmt.Println(output) } func readFile(path string) ([]byte, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() byteValue, err := ioutil.ReadAll(file) return byteValue, nil }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a context.yml file contains:
ARRAY: ['elem1', 'elem2', 'elem3']
template.conf file contains:
array: {{ ARRAY }}
I did templating and expected output is:
array: ['elem1', 'elem2', 'elem3']
and actual output is:
array: <[]interface {} Value>
code snippet:
The text was updated successfully, but these errors were encountered: