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

unrecognized variable name #10

Open
markokocic opened this issue Mar 11, 2021 · 2 comments
Open

unrecognized variable name #10

markokocic opened this issue Mar 11, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@markokocic
Copy link
Collaborator

markokocic commented Mar 11, 2021

Not sure if this is templatel or weblorg issue, filling it here.

I have defined a template variable named date-format inside a weblorg-site definition.

When I try to generate the website, I get the following error message:

Template Error: home.html: Variable `date' not declared
@clarete
Copy link
Collaborator

clarete commented Mar 14, 2021

hi @markokocic! thank you for opening the issue. I think this is indeed on templatel's side, and it might unfortunately be by design. The reason this happens is that the dash between the two words is seen as the infix operator for subtraction within templatel.

That's indeed a long way to say that templatel's variables must match the expression [a-zA-Z_][a-zA-Z0-9_]*. In other words, the first character must be either a letter between a and z or underscore, and the rest of the name can also contain numbers.

Emacs Lisp uses prefix notation since everything is implemented as functions, but there is no great translation between that and Jinja2's syntax which is built after Python's infix. I decided to follow Jinja's style as the overall direction of templatel, so I think we should at the very least get this exact example and add it to the documentation, because I believe this might be confusing other people as well.

Once again, thanks for raising the issue! 🙇🏾

@clarete clarete added the documentation Improvements or additions to documentation label Mar 14, 2021
@markokocic
Copy link
Collaborator Author

Thanks, @clarete, looks like it was just wrong expectations from my side that variable names will follow lisp rules instead of python rules. You are right, having one example might mitigate the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants