learnlytics-go/templ/generator/test-once/template.templ
2025-03-20 12:35:13 +01:00

20 lines
395 B
Plaintext

package once
var helloHandle = templ.NewOnceHandle()
templ hello(label, name string) {
@helloHandle.Once() {
<script>
function hello(name) {
alert('Hello, ' + name + '!');
}
</script>
}
<input type="button" value={ label } data-name={ name } onclick="hello(this.getAttribute('data-name'))"/>
}
templ render() {
@hello("Hello User", "user")
@hello("Hello World", "world")
}