@@ -6,7 +6,7 @@ Use standard `<script>` tags, and standard HTML attributes to run JavaScript on
66
77``` templ
88templ body() {
9- <script type="text/javascript" >
9+ <script>
1010 function handleClick(event) {
1111 alert(event + ' clicked');
1212 }
@@ -49,7 +49,7 @@ HTML element `on*` attributes pass an event object to the function. To pass the
4949:::
5050
5151``` templ title="input.templ"
52- <script type="text/javascript" >
52+ <script>
5353 function clickHandler(event, message) {
5454 alert(message);
5555 event.preventDefault();
@@ -61,7 +61,7 @@ HTML element `on*` attributes pass an event object to the function. To pass the
6161The output would be:
6262
6363``` html title="output.html"
64- <script type = " text/javascript " >
64+ <script >
6565 function clickHandler (event , message ) {
6666 alert (message);
6767 event .preventDefault ();
@@ -87,7 +87,7 @@ templ InitializeClientSideScripts(data CustomType) {
8787This will output a ` <script> ` tag that calls the ` functionToCall ` function with the ` Name ` and ` Age ` properties of the ` data ` object.
8888
8989``` html title="output.html"
90- <script type = " text/javascript " >
90+ <script >
9191 functionToCall (" John" , 42 );
9292 </script >
9393```
@@ -169,15 +169,15 @@ var helloHandle = templ.NewOnceHandle()
169169templ hello(label, name string) {
170170 // This script is only rendered once per HTTP request.
171171 @helloHandle.Once() {
172- <script type="text/javascript" >
172+ <script>
173173 function hello(name) {
174174 alert('Hello, ' + name + '!');
175175 }
176176 </script>
177177 }
178178 <div>
179179 <input type="button" value={ label } data-name={ name }/>
180- <script type="text/javascript" >
180+ <script>
181181 // To prevent the variables from leaking into the global scope,
182182 // this script is wrapped in an IIFE (Immediately Invoked Function Expression).
183183 (() => {
@@ -213,7 +213,7 @@ var surrealHandle = templ.NewOnceHandle()
213213
214214templ hello(label, name string) {
215215 @helloHandle.Once() {
216- <script type="text/javascript" >
216+ <script>
217217 function hello(name) {
218218 alert('Hello, ' + name + '!');
219219 }
@@ -224,7 +224,7 @@ templ hello(label, name string) {
224224 }
225225 <div>
226226 <input type="button" value={ label } data-name={ name }/>
227- <script type="text/javascript" >
227+ <script>
228228 // me("-") returns the previous sibling element.
229229 me("-").addEventListener('click', function() {
230230 let name = this.getAttribute('data-name');
@@ -492,9 +492,9 @@ After building and running the executable, running `curl http://localhost:8080/`
492492``` html title="Output"
493493<html >
494494 <body >
495- <script type = " text/javascript " >function __templ_printToConsole_5a85 (content ){console .log (content)} </script >
496- <script type = " text/javascript " >__templ_printToConsole_5a85 (" 2023-11-11 01:01:40.983381358 +0000 UTC" ) </script >
497- <script type = " text/javascript " >__templ_printToConsole_5a85 (" Again: 2023-11-11 01:01:40.983381358 +0000 UTC" ) </script >
495+ <script >function __templ_printToConsole_5a85 (content ){console .log (content)} </script >
496+ <script >__templ_printToConsole_5a85 (" 2023-11-11 01:01:40.983381358 +0000 UTC" ) </script >
497+ <script >__templ_printToConsole_5a85 (" Again: 2023-11-11 01:01:40.983381358 +0000 UTC" ) </script >
498498 </body >
499499</html >
500500```
0 commit comments