File tree Expand file tree Collapse file tree 3 files changed +4
-24
lines changed Expand file tree Collapse file tree 3 files changed +4
-24
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import Control.Monad (join)
3333import qualified Text.Inflections
3434import qualified Data.Text as Text
3535import Text.Countable (singularize , pluralize )
36+ import qualified Data.Text.Slugger
3637
3738-- | Transforms a underscore table name to a camel case model name.
3839--
@@ -245,17 +246,7 @@ haskellKeywords = [ "_"
245246-- >>> toSlug "Hallo! @ Welt"
246247-- "hallo-welt"
247248toSlug :: Text -> Text
248- toSlug text =
249- text
250- |> Text. toLower
251- |> Text. map replaceChar
252- |> Text. words
253- |> Text. intercalate " -"
254- where
255- replaceChar 'ä' = ' a'
256- replaceChar 'ö' = ' o'
257- replaceChar 'ü' = ' u'
258- replaceChar char = if Char. isAlphaNum char && Char. isAscii char then char else ' '
249+ toSlug text = Data.Text.Slugger. toSlug text
259250
260251
261252-- | Transform a data-field name like @userName@ to a friendly human-readable name like @User name@
Original file line number Diff line number Diff line change @@ -113,16 +113,4 @@ tests = do
113113 escapeHaskellKeyword " DATA" `shouldBe` " DATA_"
114114
115115 it " should ignore non-haskell keywords" do
116- escapeHaskellKeyword " hello" `shouldBe` " hello"
117-
118- describe " toSlug" do
119- it " should deal with empty input" do
120- toSlug " " `shouldBe` " "
121-
122- it " should make a slug string from a string" do
123- toSlug " IHP Release: 21.08.2020 (v21082020)" `shouldBe` " ihp-release-21-08-2020-v21082020"
124- toSlug " Hallo! @ Welt" `shouldBe` " hallo-welt"
125-
126- it " should deal with umlaute" do
127- toSlug " käuferpass" `shouldBe` " kauferpass"
128- toSlug " äöüß" `shouldBe` " aou"
116+ escapeHaskellKeyword " hello" `shouldBe` " hello"
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ common shared-properties
136136 , stm
137137 , wai-asset-path
138138 , wai-flash-messages
139+ , slugger
139140 default-extensions :
140141 OverloadedStrings
141142 , NoImplicitPrelude
You can’t perform that action at this time.
0 commit comments