templ icon indicating copy to clipboard operation
templ copied to clipboard

bug: backslashes in constant string attributes cannot be generated

Open zmzlois opened this issue 11 months ago • 3 comments

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.

zmzlois avatar Mar 17 '24 16:03 zmzlois