mustache-haskell 0.1.0.1 → 0.1.0.2
raw patch · 4 files changed
+25/−15 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Main.hs +10/−6
- README.md +3/−2
- Text/Mustache/Parse.hs +11/−6
- mustache-haskell.cabal +1/−1
Main.hs view
@@ -1,7 +1,6 @@ module Main where import Text.Mustache import qualified Text.Show.Pretty as Pr-import System.Environment import Data.Aeson import qualified Data.Text.Lazy.IO as TL import qualified Data.ByteString.Lazy.Char8 as BL@@ -10,28 +9,33 @@ import Data.Maybe import qualified Text.Show.Pretty as Pr import Options.Applicative+import System.Directory -data Options = Options Bool FilePath deriving (Show)+data Options = Options Bool (Maybe FilePath) FilePath deriving (Show) parseOpts :: Parser Options parseOpts = Options <$> (flag False True (short 'c' <> help "Just output parse tree of template file"))- <*> (argument str (metavar "FILE"))+ <*> (Just <$> (strOption (short 'd' <> metavar "TEMPLATE_DIRECTORY" <> help "Template directory")) <|> pure Nothing)+ <*> (argument str (metavar "TEMPLATE_FILE")) opts = info (helper <*> parseOpts) (fullDesc <> progDesc "A Haskell implementation of Mustache templates.\nOn STDIN provide the JSON to insert into the template."- <> header "mus v0.1.0.1")+ <> header "mus v0.1.0.2") main = do opts' <- execParser opts case opts' of- Options True file -> do+ Options _ (Just dir) _ -> setCurrentDirectory dir+ _ -> return ()+ case opts' of+ Options True _ file -> do s <- readFile file xs <- readTemplate s putStrLn $ Pr.ppShow xs- Options False file -> do+ Options False _ file -> do s <- readFile file chunks <- readTemplate s input <- BL.getContents
README.md view
@@ -31,15 +31,16 @@ ``` ```-mus v0.1.0.0+mus v0.1.0.2 -Usage: mus [-c] FILE+Usage: mus [-c] [-d TEMPLATE_DIRECTORY] TEMPLATE_FILE A Haskell implementation of Mustache templates. On STDIN provide the JSON to insert into the template. Available options: -h,--help Show this help text -c Just output parse tree of template file+ -d TEMPLATE_DIRECTORY Template directory ``` ## List separator syntax
Text/Mustache/Parse.hs view
@@ -29,12 +29,17 @@ loadPartial :: Chunk -> IO [Chunk] loadPartial (Partial path) = do- e <- doesFileExist path- if e - then do- s <- readFile path- return $ runParse s - else error $ "Partial file missing: " ++ path+ file <- do e <- doesFileExist path+ if e + then return path+ else do+ let path' = path ++ ".mustache"+ e' <- doesFileExist path'+ if e'+ then return path'+ else error $ "Partial file missing: " ++ path+ s <- readFile file+ return $ runParse s loadPartial (Section k cs sep) = do cs' <- mapM loadPartial cs return [Section k (concat cs') sep]
mustache-haskell.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mustache-haskell -version: 0.1.0.1+version: 0.1.0.2 synopsis: Straight implementation of mustache templates description: Straight implementation of mustache templates homepage: https://github.com/danchoi/mustache-haskell