Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Inverted browser.getBrowser if statement

Started by Muut Archive 9 years ago · 4 replies · 406 views
9 years ago

I use a glsl Canvas with a custom shader. It all works well, only firefox has some serious performance issues. Since its a known bug and there is no workaround i know of, i want to exclude specific scripts only for firefox. So i tried to invert the browser.getBrowser Twig thingy, but ..

TWIG
        {% if not browser.getBrowser == 'firefox' %}
            {% do assets.addJs('theme://js/GlslCanvas.js', 99) %}
            {% do assets.addJs('theme://js/canvas.js',  {group: 'bottom'}) %}
        {% endif %}

... does not work. I tried several other iterations of the not statement, but i never get it to work. Since its my first time using grav and twig, i just think i am missing something obvious. can you guys help me out?

9 years ago

Should that conditional be {% if browser.getBrowser != 'firefox' %}?

9 years ago

strange, i thought i tried that... but it seems to work now, so thank you very much!

9 years ago

Its a bit of the Twig-syntax that often gets overlooked, because if not this equals 'this' seems logically valid - if not altogether well-structured - but it's not. if browser.getBrowser not 'firefox' would work as well, but it's often nice to include the "stricter" comparison operator if you need to do type-checking at the same time.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1327 9 years ago
Archive · by Muut Archive, 9 years ago
2 921 9 years ago
Archive · by Muut Archive, 9 years ago
2 4050 9 years ago
Archive · by Muut Archive, 9 years ago
1 2928 9 years ago
Archive · by Muut Archive, 9 years ago
3 1107 9 years ago