go_diego
go_diego

Reputation: 393

Using a variable with Jekyll's contain operator

Is there any way to do something like this?

{% if file.basename contains {{basename}} %}

All the examples I have seen explicitly use a value, like this:

{% if file.basename contains 'image' %}

If it matters, I'm trying to loop through site.static_files and only capture the files whose basename matches a variable passed in through an include.

Upvotes: 4

Views: 525

Answers (1)

SLaks
SLaks

Reputation: 887275

You can use the variable directly as an expression:

{% if file.basename contains basename %}

The {{ syntax is only used to print expressions from markup.

Upvotes: 5

Related Questions