We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This code:
{% script functionName(a int, b int) %} alert(a+b); {% endscript %}
Will render:
<script>function functionName(a, b){alert(a+b};}</script>
{% script %}
{% templ ScriptBlocksNotSupported(script string) %} <script type="text/javascript"> {%= script %} </script> {% endtempl %}
{% templ BasicTemplate() %} <div> <a onClick="alert('hello');">{%= "Say hello" %}</a> </div> {% endtempl %}
The Google SafeHTML code describes how this can work: https://github.com/google/safehtml/blob/2057dd9c30f9e264f4d01c29d886d51f1b519302/script.go#L67
The named variables are inserted into the JavaScript template JSON escaped.
templ.RawScript
This is described in the documentation, but not provided to encourage not doing that.
The text was updated successfully, but these errors were encountered:
feat: added component JavaScript support, see #23
3784d4e
bd42ac9
No branches or pull requests
Script blocks support
This code:
Will render:
Script blocks should not support script tags at all and should warn to use the
{% script %}
template insteadonClick / on* handlers should support constant values as well as
{% script %}
templatesDynamic onClick / on* handlers with templates use sanitised values by forcing the use of
{% script %}
templatesThe Google SafeHTML code describes how this can work: https://github.com/google/safehtml/blob/2057dd9c30f9e264f4d01c29d886d51f1b519302/script.go#L67
The named variables are inserted into the JavaScript template JSON escaped.
To render raw scripts, a
templ.RawScript
component can be usedThis is described in the documentation, but not provided to encourage not doing that.
The text was updated successfully, but these errors were encountered: