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.

While in­cor­po­rat­ing more of IndieWeb into my web­site, I found my­self im­ple­ment­ing an iden­ti­cal logic in two tem­plat­ing lan­guages: Liquid and Nunjucks.

To check whether a string ex­ists in an ar­ray, this is how you would do it in each lan­guage.

In Liquid:

{% if data.publish-to contains 'mastodon' %}

In Nunjucks:

{% if 'mastodon' in data['publish-to'] %}

Accessing prop­er­ties with spe­cial char­ac­ters

In our ex­am­ple, an­other thing of note is how a prop­erty on the data ob­ject with a hy­phen in its name — publish-to — is be­ing re­trieved.

Liquid com­fort­ably un­der­stands what is called the dot no­ta­tion in JavaScript. This is quite im­pres­sive.

Nunjucks needs what is called the bracket no­ta­tion in JavaScript.