Skip to content

String literals in single quotation marks #283

Open
@davidchall

Description

@davidchall

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions