Skip to content
Browse files

normalize names more

  • Loading branch information...
1 parent ae01e70 commit a98a80c114ee442ddb9d3423d0b445255e033d81 @singpolyma committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 mustache2hs.hs
View
8 mustache2hs.hs
@@ -272,11 +272,15 @@ codeGen path (rname,rec) recs _ (MuPartial name) =
codeGen _ _ _ _ _ = return (mempty, [], [])
camelCasePath :: FilePath -> Text
-camelCasePath = T.pack . go
+camelCasePath = T.pack . lowerHead . go
where
+ lowerHead [] = []
+ lowerHead (c:cs) = toLower c : cs
go ('/':'/':cs) = go ('/' : cs)
go ('/':c:cs) = toUpper c : go cs
- go (c:cs) = c : go cs
+ go (c:cs) -- skip characters that cannot got in a name
+ | isAlpha c || isDigit c || c == '_' = c : go cs
+ | otherwise = go cs
go [] = []
codeGenFile :: Records -> (FilePath, String) -> StateT [(FilePath, String)] IO (Builder, [(FilePath, String)])

0 comments on commit a98a80c

Please sign in to comment.
Something went wrong with that request. Please try again.