Skip to content
New issue

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

[FEATURE] - Rework templating syntax #122

Open
michidk opened this issue Feb 19, 2023 · 2 comments
Open

[FEATURE] - Rework templating syntax #122

michidk opened this issue Feb 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@michidk
Copy link
Collaborator

michidk commented Feb 19, 2023

The templating syntax is quite nice and really safe (meaning there is no way it would conflict with escaping some other language). However, it is also quite tedious to write and read. Here is my proposal to change the syntax:

Current Syntax

IF Example:

{{@if {{WSL}} == "yes"}}
alias explorer='explorer.exe'
{{@fi}}

I know that the current syntax is heavily inspired by handlebars, though I don't quite remember why we introduced the @ sign, which seems a bit unnecessary to me.

Proposed Syntax

I think we can borrow again from a well-established templating system (that itself is inspired by Jinja and Django): https://github.com/Keats/tera

{% if WSL == "yes" %}
alias explorer='explorer.exe'
{% endif %}

More examples: https://tera.netlify.app/docs/#control-structures

We could also consider using Tera for this. This would remove a lot of documentation and maintenance work from the project and give us lot's more features like for loops etc.

@Shemnei
Copy link
Owner

Shemnei commented Feb 19, 2023

Current Syntax

I also do not remember why we chose @ but i guess it was to make parsing it somewhat easier.

Proposed Syntax

I wanted to get ride of your custom templating for some time now, as it is not the most robust and feature rich implementation.

I thought about adding support for multiple templating languages, which then could be chosen during runtime by:

  • Setting the template variable on the dotfile entry in the profile (e.g. template: terra)
  • Setting the correct file extension on the template file (e.g. test.txt => test.txt.terra). This extension would then get removed during the deployment.

The only problem with that is, that we need to find a way to let those template engines access the system environment (maybe some of them have already build in functions for that).

@michidk
Copy link
Collaborator Author

michidk commented Feb 19, 2023

I would not overengineer it, I think supporting only terra (for now) is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants