Allowing javascript to be set for component and page snippet properties

I’m wanting to create a component that can be used as a page snippet that allows javascript and/or script tags to be set for component properties.

I want to do this so my client can add embedded forms anywhere they like within a static page layout.

I’ve got it set up like I would expect it to, but when I added the script tag into the property of a page snippet. The values get stripped out.

Is this related to the rich editor stripping out script tags or is it something to do with how October handles properties?

If it’s the rich editor stripping out javascript and script tags is there a way for them to be allowed?

Hey @neil-impelling

I’m unsure if this is relevant, but take a look at the demo theme in v3. It has a landing page builder and one of the blocks injects custom JS and CSS to the page when it is used. It happens via the resources component and even prevents duplicates.

## themes/demo/partials/blocks/team-leaders.htm
[resources]
less[] = "blocks/team-leaders.less"
js[] = "blocks/team-leaders.js"
==
...

When this partial/snippet is used, it will inject the assets to the page via the resources component.

Regarding the specifics, can you give an example value that is getting stripped?

The V3 thing sounds ideal so I’ll have a look at this.

These are the values I’m trying to set in properties of my component with a type of string

<script charset="utf-8" type="text/javascript" src="//example.net/forms.js"></script>
<script>
myForms.create({
    portalId: "12121212121212",
    formId: "1111-2222-3333-4444"
});

</script>

I’ve tried adding script to the allowed markup tags in the editor settings, but it’s still getting stripped out. I guess it’s because it’s going to mark the markup invalid on the elements data attributes.

@daftspunky

I’ve had a look at the V3 demo theme and it’s not quite what I’m after.

I need to be able to give admins a way to embed things, within a static page.