Embed script code snippet

Enonic version: 7.12.2

How can I embed a script code snippet to an Article without the code beeing auto removed? There is a macro for embedding iframes, but nothing for script.

The specific code I am trying to embed is from Checkin.no.

When trying to implement the code via the HTML editor, the code is removed once I hit the save button.

1 Like


For security reasons, editors can and should not be able to inject scripts. If your goal is that an editor shall insert a “checkin.no” component in the middle of the text, you should probably implement a Macro: Macros - Enonic Developer Portal

The link above also includes an implementation example if you are rendering with the Enonic Framework

1 Like

If the code snippet you need to inject is exactly the same for all articles, then this can also be done via simple injection of a script tag using response processor. Important part here is that this script would only be injected in “live” mode, so Content Studio’s Content Security Policy will not be bothered.

Here’s an example.

1 Like

Thank you for the suggestion. The snippet will be different for each time. I think the development of a new macro will be our best way forward in this matter.