packages feed

mustache-haskell 0.1.0.2 → 0.1.0.3

raw patch · 6 files changed

+58/−8 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Text.Mustache.Types: Comment :: KeyPath -> Chunk
+ Text.Mustache.Types: Comment :: Text -> Chunk

Files

Main.hs view
@@ -23,7 +23,7 @@           (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.2")+            <> header "mus v0.1.0.3")  main = do     opts' <- execParser opts 
+ NOTES view
@@ -0,0 +1,2 @@+* [array elements in mustache](http://stackoverflow.com/questions/8567413/index-of-an-array-element-in-mustache-js)+
README.md view
@@ -1,17 +1,31 @@ # mustache-haskell -A Haskell implementation of mustache templates.+A Haskell implementation of mustache templates. Expects input data to be JSON.   Should be compatible with the the [mustache-specification](http://mustache.github.io/mustache.5.html).+specification](http://mustache.github.io/mustache.5.html).  Except lambdas are+not supported. +Supported syntax: +* basic variables+* sections+* inverted sections+* comments (are suppressed)+* partials+* set delimiter++This project currently only provides a command line interface.+Later versions will provide a library API for templating ToJSON+instances.++ ## Install  You need the Haskell platform on your system.  ```-cabal install mustache+cabal install mustache-haskell ```  Or alternatively@@ -31,7 +45,7 @@ ```  ```-mus v0.1.0.2+mus   Usage: mus [-c] [-d TEMPLATE_DIRECTORY] TEMPLATE_FILE   A Haskell implementation of Mustache templates. On STDIN provide the JSON to@@ -65,4 +79,28 @@ ```json {"hobbies":[{"name":"sewing"},{"name":"brewing"},{"name":"cooking"}]} ```+++## Performance++In a few informal tests, ++```+mus template.mustache < input.json+```++is about 10x faster than the Ruby mustache gem command-line implementation,++```+mustache - template.mustache < input.json+```+++## Related projects++* [whiskers](https://github.com/nejstastnejsistene/whiskers) Mustache templates with Template Haskell ([reddit](http://www.reddit.com/r/haskell/comments/2kjgg2/whiskers_moustache_templates_with_template_haskell/))+* [hastache](https://github.com/lymar/hastache) Haskell implementation of Mustache templates+* [mustache2hs](http://hackage.haskell.org/package/mustache2hs) takes in Haskell records (single data constructor only) and a list of mustache template and record name pairs, and generates Haskell code for functions that take an escape function and one of the records+* [mustache.go](https://github.com/hoisie/mustache) an implementation of the mustache template language in Go+ 
Text/Mustache/Parse.hs view
@@ -80,6 +80,7 @@     , try invertedSection     , try setDelimiter     , try partial+    , try comment     , plain     ] @@ -134,9 +135,18 @@ closeTag k = try (inDelimiters (char '/' *> string k'))    where k' = keyPathToString k -partial = do+partial =    Partial <$> (inDelimiters ((char '>' >> spaces) *> filename)) +comment = do+  Comment <$> (inDelimiters ((char '!' >> spaces) *> commentText))++commentText  = do+    notFollowedBy rightDelimiter+    x <- anyChar+    xs <- manyTill anyChar bumpClose+    return . T.pack $ x:xs+   filename :: Parser String filename = (many1 (alphaNum <|> oneOf "/.[]0-9_")) <?> "filename" 
Text/Mustache/Types.hs view
@@ -6,10 +6,10 @@          | UnescapedVar KeyPath          | Section KeyPath [Chunk] (Maybe Text)  -- separator text          | InvertedSection KeyPath [Chunk]-         | Comment KeyPath          | SetDelimiter String String -- a stateful operation          | Plain Text          | Partial FilePath+         | Comment Text          deriving (Show, Read, Eq)  type KeyPath = [Key]
mustache-haskell.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mustache-haskell -version:             0.1.0.2+version:             0.1.0.3 synopsis:            Straight implementation of mustache templates description:         Straight implementation of mustache templates  homepage:            https://github.com/danchoi/mustache-haskell