2
votes

i want to use my twig for the condition if the route is blank then it will use home.color_scheme else it will use setting.color_scheme. Here's my code:

{% if home.color_scheme != 'default' or setting.color_scheme != 'default'  %}
    <link href="/css/color-variations/{% route == '' ? home.color_scheme : setting.color_scheme  %}.css" rel="stylesheet" type="text/css" media="screen">
{% endif %}

but it makes some error like this:

 'Unexpected "route" tag (expecting closing tag for the "if" tag defined near line 17).'

so what makes this error and how I can fix it?

1

1 Answers

2
votes

Try this:

<link href="/css/color-variations/{{ route == '' ? home.color_scheme : setting.color_scheme  }}.css" rel="stylesheet" type="text/css" media="screen">

you suppose to use {{ instead of {%.