What are I doing wrong here?

I'm setting block types 'stripCustom' and 'stripShowroom' to 'stripBlock'

{% set stripBlock = entry.contentImage.type(['stripCustom', 'stripShowroom']) %}

Then in a loop checking if 'stripBlock' is last and the current block is last but one.

<div class="section {% if loop.last == stripBlock and loop.revindex0 == 1 %}gutter-bottom--double{% endif %}">
  • 2
    I don't think you can compare loop.last to your stripBlock variable. I think loop.last just is or isn't. Commented May 5, 2017 at 16:02
  • Oh. So is there a way to test is a certain block type is last?
    – sarah3585
    Commented May 6, 2017 at 7:21
  • Did my answer below help you with your issue? Commented May 10, 2017 at 16:44
  • Haven't had a chance to look yet as I've been pulled away from that project, I will look today.
    – sarah3585
    Commented May 11, 2017 at 9:38

1 Answer 1


To test if the current block is the last in the loop and of a certain type, you could do something like:

{% if loop.last and block.type == "yourBlockType" %}yes{% endif %}

or shorthand

{{ loop.last and block.type == "yourBlockType" ? 'yes' : 'no' }}

In the above example replace 'no' with '' to output nothing. It's just there if you want to output something in case of false

or even shorter

{{ loop.last and block.type == "yourBlockType" ? 'yes' }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.