Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Javascript and non-editable HTML in Template Parts #47621

Closed
CGTS opened this issue Jan 31, 2023 · 3 comments
Closed

Allow Javascript and non-editable HTML in Template Parts #47621

CGTS opened this issue Jan 31, 2023 · 3 comments

Comments

@CGTS
Copy link

CGTS commented Jan 31, 2023

What problem does this address?

I would like to use a library like Alpine.js to build basic interactions in my pattern and parts files. It requires adding directives directly into the html. It also requires adding data into data-attributes. Both of these actions causes the edit view to return a "his block contains unexpected or invalid content." error. It works without an issue in browser. It only breaks in the editor.

What is your proposed solution?

If would be great if there way a way to indicate that the editor should ignore a piece of code allowing it to pass through to the browser without breaking the editor. This should also work for allowing html to be sent through without requiring the comments that allow it to be editable. For example I may have a template part with some decorative element that I don't want a user to edit. This would allow it to show up with appearing in the list view.

@CGTS CGTS changed the title Allow Javascript and non-editable HTML in Template Parts and Patterns Allow Javascript and non-editable HTML in Template Parts Jan 31, 2023
@carolinan
Copy link
Contributor

Is it not possible to use a locked HTML block for adding this HTML?
If not I would suggest creating a custom server rendered block - since you don't want users to edit it.

@CGTS
Copy link
Author

CGTS commented Feb 1, 2023

It may be possible to use the html block for the decorative html (Is it possible to have the block default to the preview of the html?). However, I don't believe it would be possible to use it for the inline directives. I would be adding x-data="menuOpen" to the container div and would need to add the nav block and buttons into it.

I guess I couldn't avoid building a custom block forever. I'll look into it. Thanks

@CGTS CGTS closed this as completed Feb 1, 2023
@carolinan
Copy link
Contributor

It may be possible to select the preview as default after #46834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants