Javascript compatible?

Created on 28 March 2024, 3 months ago

Problem/Motivation

I am using the Metatag module and there we can enter the field "Expire" in GMT format to show when the page will expire.
To make it dynamic I want to use javascript to do this using:

<script type="text/javascript">
const now = new Date();
const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 7, now.getHours(), now.getMinutes(), now.getSeconds());
const rfc1123DateString = tomorrow.toUTCString();

document.write(rfc1123DateString);
</script>

I tried to create a new custom token type called "cache-expire" using this code.
So this token was created: "[cache-expires:7day]" using the code above and I added this token to the metatag module.

Problem is that the javascript is not processed so the actual token shows the javascript code and not the actual GMT format date.

Does this module support javascript for the tokens? If so, how? Not sure what I did wrong.
I have a text format called "javascript". I tested this code on a regular page and the code displays the GMT date correctly, just not in this custom token module.

How do you recommend I make this work?
Sorry, I am not very familiar with this module.
Any assistance or guide you may provide is greatly appreciated.

πŸ’¬ Support request
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jsidigital

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024