Skip to content

Variable with question mark does not parse #77

@ryaninvents

Description

@ryaninvents

In Ruby, a question mark is a valid identifier character and is commonly used to denote a boolean. However, LiquidJS throws an error.

For example, this syntax is valid Liquid:

{% if form.posted_successfully? %}
  <div class="success">Success!</div>
{% endif %}

But throws an error:

RenderError: cannot eval 'form.posted_successfully?' as value, file:/home/ryan/Projects/.../contact-form.liquid, line: 27
  at renderTemplate.call.then.catch.e (/home/ryan/Projects/.../node_modules/liquidjs/src/render.js:21:17)
  at <anonymous>:null:null

From TypeError: cannot eval 'form.posted_successfully?' as value
  at evalValue (/home/ryan/Projects/.../node_modules/liquidjs/src/syntax.js:43:9)
  at Function.evalExp (/home/ryan/Projects/.../node_modules/liquidjs/src/syntax.js:30:10)
  at Object.render (/home/ryan/Projects/.../node_modules/liquidjs/tags/if.js:35:27)
  at Promise.resolve.then (/home/ryan/Projects/.../node_modules/liquidjs/src/tag.js:27:48)
  at <anonymous>:null:null

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