Twig js, if url contains ‘batch’

734 Views Asked by At

I’m new to a project using Twig js. I’ve been playing around with a template trying to get it to work but with no luck.

Is there anyway of writing.

If url contains ‘batch-‘ then load these 2 CSS files, else load this 1 CSS file?

Any help is greatly appreciated,

Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

In order to do that you'll have to pass the url that you want to check to the template and then you'll be able to add the following:

{% if 'batch-' in url %}
    <link rel="stylesheet" href="style1.css">
    <link rel="stylesheet" href="style2.css">
{% else %}
    <link rel="stylesheet" href="style1.css">  
{% endif %}