template-hsml 0.2.0.2 → 0.2.0.3
raw patch · 6 files changed
+27/−14 lines, 6 files
Files
- src/Template/HSML.hs +4/−2
- src/Template/HSML/Internal/Parser.hs +1/−0
- src/Template/HSML/Internal/Parser/Syntax.hs +13/−5
- src/Template/HSML/Internal/TH.hs +1/−0
- src/Template/HSML/Internal/Types.hs +1/−0
- template-hsml.cabal +7/−7
src/Template/HSML.hs view
@@ -15,7 +15,9 @@ -- > element_leaf = "<" element_name { attribute } "/>" ; -- > haskell = "{h|" expression | declaration "|}" ; -- >--- > attribute = attribute_name "=" attribute_value ;+-- > attribute = attribute_exp | attribute_normal+-- > attribute_exp = "{h|" expression "|}"+-- > attribute_normal = attribute_name "=" attribute_value ; -- > attribute_name = ? classic attribute name ? | "{h|" expression "|}" ; -- > attribute_value = ? classic attribute value ? | "{h| expression "|}" ; -- >@@ -91,7 +93,7 @@ -- > </body> -- > </html> ----- Result of @renderMarkup . homeTemplate [User 1 "Jon Doe" 16, User+-- Result of @renderMarkup $ homeTemplate [User 1 "Jon Doe" 16, User -- 2 "Jane Roe" 17]@: -- -- > <!DOCTYPE HTML>
src/Template/HSML/Internal/Parser.hs view
@@ -102,6 +102,7 @@ ] transformAttribute :: I.RAttribute -> P.Parser I.Attribute+transformAttribute (I.AttributeExp rexp) = I.AttributeExp <$> transformExp rexp transformAttribute (I.Attribute rname rvalue) = I.Attribute <$> transformName rname <*> transformValue rvalue where
src/Template/HSML/Internal/Parser/Syntax.hs view
@@ -102,11 +102,19 @@ -------------------------------------------------------------------------------- -- | Attribute attribute :: P.Parser I.RAttribute-attribute = do- n <- attributeName- spaces >> P.char '=' >> spaces- v <- attributeValue- return $ I.Attribute n v+attribute = P.try $+ P.try attributeNormal <|>+ attributeExp+ where+ attributeNormal :: P.Parser I.RAttribute+ attributeNormal = do+ n <- attributeName+ spaces >> P.char '=' >> spaces+ v <- attributeValue+ return $ I.Attribute n v+ + attributeExp :: P.Parser I.RAttribute+ attributeExp = I.AttributeExp <$> haskellBody attributeValue :: P.Parser I.RAttributeValue attributeValue = P.try $
src/Template/HSML/Internal/TH.hs view
@@ -282,6 +282,7 @@ applyAttributes attributes markup = foldl (B.!) markup attributes attributeToExp :: I.Options -> I.Attribute -> TH.ExpQ+attributeToExp I.Options{..} (I.AttributeExp e) = toExp e attributeToExp I.Options{..} (I.Attribute aname avalue) = [e| B.attribute (fromString $(attributeNameToExp aname)) (fromString (" " <> $(attributeNameToExp aname) <> "=\""))
src/Template/HSML/Internal/Types.hs view
@@ -143,6 +143,7 @@ | Expression Exp data PAttribute exp = Attribute (PAttributeName exp) (PAttributeValue exp)+ | AttributeExp exp data PAttributeName exp = AttributeNameText String | AttributeNameExp exp
template-hsml.cabal view
@@ -1,5 +1,5 @@ name: template-hsml-version: 0.2.0.2+version: 0.2.0.3 synopsis: Haskell's Simple Markup Language description: HSML syntax is very similar to that of XML, but there are less rules. The main advantage over plain XML or HTML is that it allows you to embed Haskell declarations@@ -32,14 +32,14 @@ hs-source-dirs: src exposed-modules:- Template.HSML + Template.HSML other-modules: - Template.HSML.Internal.TH- , Template.HSML.Internal.Types- , Template.HSML.Internal.Types.Syntax- , Template.HSML.Internal.Parser- , Template.HSML.Internal.Parser.Syntax+ Template.HSML.Internal.TH+ , Template.HSML.Internal.Types+ , Template.HSML.Internal.Types.Syntax+ , Template.HSML.Internal.Parser+ , Template.HSML.Internal.Parser.Syntax build-depends: base == 4.5.*