Closed alan-cugler closed 7 years ago
I didn't realize this happened either. Being new to Yasha, I'd have expected only jinja by default. Validating json (et al.) variable files makes sense, so they can be used. Validating the templates seems a bit out of scope though, again, at least by default. Sounds like nice icing on the cake though as an option. I'm still new though and I'm sure I don't know all Yasha's use cases. Thanks for the project :)
I'm not sure if this is Yasha related. According to traceback you are using older version. Does this happen with Yasha 4.0 too?
Yasha does not validate the template.
How does your command-line call looks like?
It looks like it's trying to load a variable file and dying on that.
Exactly. That's what I was thinking too. Workaround could be to use --no-variable-file
, or to rename the template to .foo.json.j2
My command line code was:
yasha -v --SSD=20480 ~/test.json -o ~/test_exit.json
I tested the command line code against yasha 4.0 and observed the same problem. I then took on your suggestion of --no-variable-file
and added it in to my command line code:
yasha --no-variable-file --SSD=20480 ~/test.json -o ~/test_exit.json
The code worked without a hitch!
Analysis:
The expectation of a variable file is annoying when you only need to pass in a couple variable values. It'd make sense for it to be an optional tag for feeding yasha a variable file path. At least there should be some check to give you a error feedback that is useful.
ERROR: variable-file expected
This should be fixed in 4.1. Thanks for reporting.
I have a valid .json file that works if I use it as is. This .json file has
{{ .foo }}
variables in it, which are internally processed ( these are not jinja variables) .I am attempting to take this .json file and run it through the Yasha template command to create more .json files using jinja
{{ bar }}
to replace other hard coded variable values in the .json file.If I run the .json file as is, it complains about the .json
{{ .foo }}
variables as expected. These variables can not be replaced or removed so I used the{% raw %}
as described here to omit them.My syntax looked like this:
{% raw %} ...code line...{{ .foo } }...more code...{% endraw %}
.This should have allowed Yasha to ignore the .json variables with no complaints. Instead I receive the following error:
I think this is because a json validator is being run on the file first, before jinja is used. I didn't expect any json validating.
If I change the file extension from .json to .txt it has no complaints and completes its jinja parsing correctly. I think because there is no json validating in this file extension.