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

Markdown templates #1247

Merged
merged 8 commits into from
Feb 25, 2025
Merged

Markdown templates #1247

merged 8 commits into from
Feb 25, 2025

Conversation

jochenklar
Copy link
Member

@jochenklar jochenklar commented Feb 20, 2025

This PR is the sequel to #1174. It refactors some code and adds code to execute the JS in templates. The feature can be tested with {{test}} in a help text of a question and:

<p>
    TEST!
</p>
<script>
    (function() {
        const elements = document.getElementsByTagName('p');
        setTimeout(function() {
            for (const element of elements) {
              element.style["color"] = "red";
            }
        }, 1000)
    })()
</script>

in local_app/templates/local/test.html and

INSTALLED_APPS += ['local_app']
MARKDOWN_TEMPLATES = {
    'test': 'local/test.html'
}
TEMPLATES_EXECUTE_SCRIPT_TAGS = True

in config/settings/local.py.

@MyPyDavid I am not 100% convinced about the approach in HTML.js, please check. The source is https://macarthur.me/posts/script-tags-in-react/.

@jochenklar jochenklar requested a review from MyPyDavid February 20, 2025 13:56
@jochenklar jochenklar self-assigned this Feb 20, 2025
@jochenklar jochenklar added this to the RDMO 2.3.0 milestone Feb 20, 2025
nievax and others added 4 commits February 25, 2025 11:41
@jochenklar jochenklar force-pushed the markdown_templates branch 2 times, most recently from 9701249 to 3703084 Compare February 25, 2025 11:14
@jochenklar
Copy link
Member Author

I rebased to 2.3.0 (and removed some superfluous commits) and added TEMPLATES_EXECUTE_SCRIPT_TAGS to settings instead of the data-execute="true" pattern. Ready for review!

Copy link
Member

@MyPyDavid MyPyDavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, tests have passed.

@jochenklar jochenklar merged commit b050b1c into 2.3.0 Feb 25, 2025
19 checks passed
@jochenklar jochenklar deleted the markdown_templates branch February 25, 2025 19:57
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

Successfully merging this pull request may close these issues.

3 participants