0

In order to sort an array of strings in a javascript table effect using Velocity templates, I need to replace accent characters for normalized ones (i.e. 'é' for 'e'). I know to use replace method in Velocity but I would ask for something more sophisticated. XD

Cœur
  • 37,241
  • 25
  • 195
  • 267
Pymoo
  • 127
  • 1
  • 4
  • 11
  • If you need this for JS, then you should do it in JS, see http://stackoverflow.com/questions/227950/programatic-accent-reduction-in-javascript-aka-text-normalization-or-unaccenting – serg Sep 12 '11 at 17:28
  • The result will be used in a Javascript script, but the information is stored in velocity variables, so I need the replacement in velocity. – Pymoo Sep 12 '11 at 20:31

1 Answers1

2

Velocity is not the best tool when it comes to data manipulation, it was designed to display the data, not modify it. It is a templating language after all, not programming.

I would either strip accents on java side, or pass velocity var to javascript and strip accents there (example).

Community
  • 1
  • 1
serg
  • 109,619
  • 77
  • 317
  • 330
  • So this meants that in velocity there's no built-in method for replace accented character using bitmasks and regular expressions like in javascript. I couldn't have the same result with String.replace in velocity? – Pymoo Sep 13 '11 at 06:53
  • 1
    @Pymoo There is no built-in method in velocity, you can use `String.replace`, or build your own custom velocity directive (in java). – serg Sep 13 '11 at 15:54