Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework 2 slugify

I want to slugify an object's String attr to use it in urls. I've read that there was a function called "slugify" in play 1.x, but i can't find it in play 2.x

What's the best method to slugify a String in play 2.x?

If i have to implement the function (or any helper function like this) where should I place it for best accessibility for the whole mvc?

like image 478
4spir Avatar asked Sep 27 '26 22:09

4spir


1 Answers

As noted in https://groups.google.com/forum/#!topic/play-framework/r-raDXl95Q4, there is no builtin slugify helper in Play 2. But it's easy enough to build your own. Here's one example:

https://github.com/julienrf/chooze/blob/master/app/util/Util.scala#L6

The author places the helper under app/util, which is as reasonable a place as any, IMO.

like image 121
Brian Clapper Avatar answered Sep 30 '26 12:09

Brian Clapper