Twig if statement to select page template?

Is there a way to select a page template from an “if” statement? I would image there is, but I cannot find it. haha. Something like:

I’m trying to add a body class to my modular page without having to rely on doing it through the front-matter.

Here’s what I have in my base.html.twig:

I read in documentation how to do stuff like that from the front matter, but not from the actual page template. Doing it though the blueprint would also be an option if that’s possible.

Very close! You can do something like:

<body class="{% if page.template == modular %} modular-page{% endif %}">

You can add the body_classes block too, but it’s not required for this example.

Ahhh. SO. freaking. close. I must have tried a dozen different strings. haha

Thanks for the help!

Ok, looks like I may need to add the body_class block in there because it’s not showing the new class in the html. I tried putting that if statement inside of the current

but it didn’t print. I promise, I’m going to figure out this syntax eventually. haha

Need that {% endblock %} on the end to close the block.

Writing like this though, isn’t showing the added body class on the front end.

Sorry, can’t figure out how to post code from my iPad.