Liquid’s capture always returns a string!

Be aware this is a draft post — please adjust your expectations accordingly. Get in touch if this post could use an improvement.

This keeps tripping me up!

I use liquid templates a lot. In a capture block, the result of any operation will always be a string.

If you call a custom shortcode written in JavaScript that returns a boolean, the capture block would convert that to "true" or "false".

Then, if you check for truthy-ness of the captured variable down the line, you’ve got to compare it with a specific string: capturedVariable == "true"


Comment via email.