You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be cool and practical to allow using templ components in templ script components.
In my opinion it would be especially useful for native web components.
Simple example:
templtodoItem(textstring){
<li> { text } </li>
}
templtodoList(){
<ulid="todo-list"></ul><inputtype="text"id="todo-input"/><buttononclick={ addTodo() }>add</button>
}
scriptaddTodo() {
constitemText=document.getElementById("todo-input").value;
constitem= @todoItem(itemText); // maybe just render the component to a javascript function, which returns the component either as a string or as a HTML component constlist=document.getElementById("todo-list");
list.appendChild(item);
}
This also would make code formatting much easier, since one wouldn't have to create those inline elements as strings.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I think it would be cool and practical to allow using templ components in templ script components.
In my opinion it would be especially useful for native web components.
Simple example:
This also would make code formatting much easier, since one wouldn't have to create those inline elements as strings.
PS: I love this project! :)
Beta Was this translation helpful? Give feedback.
All reactions