diff --git a/src/Template/HSML.hs b/src/Template/HSML.hs
--- a/src/Template/HSML.hs
+++ b/src/Template/HSML.hs
@@ -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>
diff --git a/src/Template/HSML/Internal/Parser.hs b/src/Template/HSML/Internal/Parser.hs
--- a/src/Template/HSML/Internal/Parser.hs
+++ b/src/Template/HSML/Internal/Parser.hs
@@ -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
diff --git a/src/Template/HSML/Internal/Parser/Syntax.hs b/src/Template/HSML/Internal/Parser/Syntax.hs
--- a/src/Template/HSML/Internal/Parser/Syntax.hs
+++ b/src/Template/HSML/Internal/Parser/Syntax.hs
@@ -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 $
diff --git a/src/Template/HSML/Internal/TH.hs b/src/Template/HSML/Internal/TH.hs
--- a/src/Template/HSML/Internal/TH.hs
+++ b/src/Template/HSML/Internal/TH.hs
@@ -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) <> "=\""))
diff --git a/src/Template/HSML/Internal/Types.hs b/src/Template/HSML/Internal/Types.hs
--- a/src/Template/HSML/Internal/Types.hs
+++ b/src/Template/HSML/Internal/Types.hs
@@ -143,6 +143,7 @@
              | Expression  Exp
 
 data PAttribute exp = Attribute (PAttributeName exp) (PAttributeValue exp)
+                    | AttributeExp exp
 
 data PAttributeName exp = AttributeNameText String 
                         | AttributeNameExp  exp
diff --git a/template-hsml.cabal b/template-hsml.cabal
--- a/template-hsml.cabal
+++ b/template-hsml.cabal
@@ -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.*
