Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Custom JS in Page Grav1.7

Solved by Carl R LeBlond View solution

Started by Carl R LeBlond 5 years ago · 4 replies · 589 views
5 years ago

I've upgraded a site from Grav1.6 to Grav1.7. In some pages I have custom javascript in script tags in page.md. This works fine in 1.6, but in 1.7 it seems to wrap the js in <![CDATA[ ]] and does not work. Any ideas?
Carl

👍 1
last edited 01/28/22 by Carl R LeBlond
5 years ago

@cleblond, I cannot reproduce the issue using Grav 1.7.28 when embedding the following inside page Typography:

HTML
<script>
  alert('Hello world!');
</script>

it seems to wrap the js in <![CDATA[ ]]

Does it seem to be so, or do you know it is so? I haven't seen that behaviour before.

5 years ago

It's definitely wrapping in CDATA. I get console error (Uncaught SyntaxError: Unexpected token '<') from the <![CDATA[ ]] and it there when I inspect. I'm using the learn-git-sync theme. I've read the upgrade docs. I'll have another look.

5 years ago

@cleblond, Theme Learn2 Git Sync is compatible with Grav 1.7 with respect to Twig auto-escape.

I haven't tested other aspects.

5 years ago Solution

Thanks @pamtbaau. When I disabled the tinymce editor integration the problem went away. Odd that this didn't occur in 1.6.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 1 week ago
0 140 1 week ago
General · by lynbor, 1 month ago
3 456 2 weeks ago
General · by lynbor, 3 weeks ago
7 591 2 weeks ago
General · by Harry, 2 weeks ago
0 178 2 weeks ago
General · by Old Man Umby, 1 month ago
2 319 4 weeks ago