nuejs / nue

A content first web framework. Perfect for UX developers.
https://nuejs.org
MIT License
5.86k stars 171 forks source link

When '{}' or',' in html , How to escape? #252

Open yuhengliang opened 1 month ago

yuhengliang commented 1 month ago

<input type="text" name="captcha" value="" placeholder="" required pattern="^\d{4,5}$" />

When '{}' or',' in html , How to escape?

nobkd commented 1 month ago

I thought, something like this pattern="{'^\d{4,5}$'}" or this :pattern="'^\d{4,5}$'" would work, but it seems, the shortest match of {} is taken resulting in pattern="{'^\d45$'}" and pattern="'^\d45$'" respectively

So you currently have to do for example something like the following:

<div>
  <p>e.g. a layout component or area or some other scope</p>
  <input type="text" name="captcha" value="" placeholder="" required :pattern />
  <!-- or -->
  <input type="text" name="captcha" value="" placeholder="" required :pattern="patternvar" />

  <script>
    pattern = '^\d{4,5}$'
    // or
    patternvar = 'some pattern'
  </script>
</div>

Hope that helps, at least until there is a proper fix :)