templ
templ copied to clipboard
bug: backslashes in constant string attributes cannot be generated
This issue is circling back to to https://github.com/a-h/templ/issues/498
On top of Lsp support, HTML's input element has a built in attribute pattern which:
- allows us to validate user's input in the browser with regular expression
- custom error message on input field with setCustomValidity
Previously I had a case of validating url links and this pattern (https?|ftp):\/\/[^\s/$.?#].[^\s]*
worked in javascript, but it doesn't work in templ or Golang (tried passing it from backend as a string). templ lsp and parser will warn me with a red flag and causing generation failure at \s
.
The alternative of not having this feature is either use additional javascript + bundle to add input validation or using validation from htmx where the lsp + syntax highlighting features are not yet complete.