harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.5k stars 237 forks source link

fix: use drop `valueOf` when evaluated as solitary condition #705

Closed admtnnr closed 3 months ago

admtnnr commented 3 months ago

Context

I noticed an inconsistency with drops where a drop's value will go through normal value resolution if used in an expression like if drop > 10, but it does not if the drop is the only part of the expression like if drop which causes it to always evaluate as truthy (because it's an object).

Shopify's Liquid implementation doesn't seem to support functionality similar to that of valueOf that we have in Liquid.js, so there's not prior art we can rely on there. Given if does seem to call valueOf when used with some type of operator I opted to make the bare drop case consistent with the existing behavior.

harttle commented 3 months ago

@all-contributors please add @admtnnr for code

allcontributors[bot] commented 3 months ago

@harttle

@admtnnr already contributed before to code

github-actions[bot] commented 2 months ago

:tada: This PR is included in version 10.14.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: