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

Custom JS in Page Grav1.7

Solved by Carl R LeBlond View solution

Started by Carl R LeBlond 5 years ago · 4 replies · 514 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 jean-louis67, 3 weeks ago
2 312 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 312 3 weeks ago
General · by Veehem, 4 weeks ago
0 264 4 weeks ago
General · by milkboy, 4 weeks ago
0 267 4 weeks ago
General · by ian russell, 1 month ago
2 337 1 month ago