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

String literals in single quotation marks #283

Open
davidchall opened this issue Nov 17, 2023 · 0 comments
Open

String literals in single quotation marks #283

davidchall opened this issue Nov 17, 2023 · 0 comments

Comments

@davidchall
Copy link

Context: Currently, inja requires string literals are specified in double quotation marks, because it follows the JSON data syntax. But templates in jinja2 can specify string literals using either single or double quotation marks.

Current behavior: It appears inja silently ignores single quotation marks, so these objects are interpreted as variables rather than string literals. For example, {{ "a" == "a" }} returns true, but {{ 'a' == 'a' }} raises error "variable 'a' not found". These error messages can confuse end users. For example, {{ join(cols, ', ') }} raises error "unknown function join".

Resolution: There are various approaches to improve this edge case. I've listed my ideas in order of preference:

  1. Accept string literals in single quotation marks (e.g., replace with double quotation marks before sending to JSON parser).
  2. Ability to configure Environment to accept string literals in single quotation marks.
  3. Recognize string literals in single quotation marks and provide informative error message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant