Notes

2020-08-10-liquid-capture-always-returns-string

📔 Note

This keeps trip­ping me up!

I use liq­uid tem­plates a lot. In a capture block, the re­sult of any op­er­a­tion will al­ways be a string.

If you call a cus­tom short­code writ­ten in JavaScript that re­turns a boolean, the cap­ture block would con­vert that to "true" or "false".

Then, if you check for truthy-ness of the cap­tured vari­able down the line, you've got to com­pare it with a spe­cific string: capturedVariable == "true"

Permalink

Published:

Caution!

This is an old post. Information here may be out-dated, or the post may re­flect opin­ions or be­liefs I no longer share.

Webmentions

Wondering how to drop a like, re­post my ar­ti­cle, or com­ment? Participate in the IndieWeb move­ment, write a note on your own site, and send me a web­men­tion.

♥ 0 likes ✏ 0 replies 📣 0 men­tions 🔁 0 re­posts