Closed fredrik-bakke closed 11 months ago
@fredrik-bakke we will be leaving TextMate grammar as a fallback highlighting mechanism. So, if you are willing to update this PR, I think we can merge it.
Great! I've resolved the merge conflict now
I get the following error on my machine:
* Executing task: python ./process_jinja_templates.py
zsh:1: command not found: python
* The terminal process "/bin/zsh '-c', 'python ./process_jinja_templates.py'" failed to launch (exit code: 127).
* Terminal will be reused by tasks, press any key to close it.
Apparently, I don't have python
globally (but I have python3
).
I guess, this is my local problem, but not entirely sure.
@aabounegm can you please check this PR on your machine as well?
I just realized I need to change one other thing. Give me a minute.
I get the following error on my machine:
* Executing task: python ./process_jinja_templates.py zsh:1: command not found: python * The terminal process "/bin/zsh '-c', 'python ./process_jinja_templates.py'" failed to launch (exit code: 127). * Terminal will be reused by tasks, press any key to close it.
Apparently, I don't have
python
globally (but I havepython3
). I guess, this is my local problem, but not entirely sure.@aabounegm can you please check this PR on your machine as well?
If you're using zsh
on Mac, then you can create an alias by adding the line
alias python=python3
to your ~/.zshrc
file.
EDIT: Never mind, this turned out to not help in this particular instance.
I will make a release without this one, as it seems not particularly important. Will make it into the next one. Hope this is okay :)
If you're using
zsh
on Mac, then you can create an alias by adding the linealias python=python3
to your
~/.zshrc
file.EDIT: Never mind, this turned out to not help in this particular instance.
Turns out you have to add the line to your ~/.zshenv
file.
I will make a release without this one, as it seems not particularly important. Will make it into the next one. Hope this is okay :)
Sure, no problem! I just figured I could make it ready for merging so that I could work with it in the future.
@fizruk It turns out the issue I was having was related to my configuration of PowerShell in VS Code, so I removed the customization and now both shell
and process
task types work.
Hello @fredrik-bakke, sorry for such a late response, but I had forgotten about this PR 😅.
To be quite frank, I'm not a big fan of Jinja templating in YAML, I barely even liked it in HTML 😁. I think in this case it could possibly lead to more unreadable config files (judging by some experience writing Helm charts) and I would far prefer using YAML's own anchors (&
) and aliases (*
) syntax.
Do you have a use case in mind in which Jinja templates would be more readable/useful or can I close this PR?
That's completely up to you! I made the PR because it was fast to do so, and I had some success using it in the past. The important thing is to have an element of metaprogramming to make the script consistent and maintainable. You can see how I use it for syntax highlighting for Agda in this file: https://github.com/fredrik-bakke/agda-syntax-vscode/blob/main/syntaxes/agda.tmLanguage.j2.yml
In the past I was looking to make some contributions to this extension and I didn't want to do that without having a metaprogramming feature in place.
Ok I see your point, but I personally find these macros and variables unreadable (especially when used inside a RegEx!) and would have a hard time maintaining them. For repeated values, we can just use anchors and aliases. Anyways, I don't think there are planned syntax changes in the near future and we already have semantic highlighting in place.
Thanks for the contribution, but I would prefer not to use Jinja templates (if anything, I personally prefer the JS format of config files supported in tools like ESLint and Prettier which allow for high flexibility and even type safety without compromising on readability)
Builds on #6. This PR adds Jinja2 templating support to YAML files. (I think it would also be possible to use it with JSON if you prefer, but I haven't tried this. It should be easy to try to modify the script to try this out.) I use only very simple features of the language, like defining reusable constants, macros, and sometimes to generate code with for loops, but it may have a lot more useful features as well.