summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Template
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-11 15:34:34 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-11 15:34:34 +0100
commit60cda32b72ce35e4c7c797be91badcb20afbe887 (patch)
tree984b0c0013f268fc98dc394224503b6b86eeddcd /src/Hakyll/Web/Template
parentdd81433d74579848e6853eb5a1500535c378c808 (diff)
downloadhakyll-60cda32b72ce35e4c7c797be91badcb20afbe887.tar.gz
Add transparent reading of hamlet/hakyll templates
Diffstat (limited to 'src/Hakyll/Web/Template')
-rw-r--r--src/Hakyll/Web/Template/Internal.hs8
-rw-r--r--src/Hakyll/Web/Template/Read/Hakyll.hs14
-rw-r--r--src/Hakyll/Web/Template/Read/Hamlet.hs2
3 files changed, 12 insertions, 12 deletions
diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs
index d0f6472..d0e0859 100644
--- a/src/Hakyll/Web/Template/Internal.hs
+++ b/src/Hakyll/Web/Template/Internal.hs
@@ -28,18 +28,18 @@ instance Writable Template where
--
data TemplateElement
= Chunk String
- | Identifier String
+ | Key String
| Escaped
deriving (Show, Eq, Typeable)
instance Binary TemplateElement where
put (Chunk string) = putWord8 0 >> put string
- put (Identifier key) = putWord8 1 >> put key
+ put (Key key) = putWord8 1 >> put key
put (Escaped) = putWord8 2
get = getWord8 >>= \tag -> case tag of
- 0 -> Chunk <$> get
- 1 -> Identifier <$> get
+ 0 -> Chunk <$> get
+ 1 -> Key <$> get
2 -> return Escaped
_ -> error $ "Hakyll.Web.Template.Internal: "
++ "Error reading cached template"
diff --git a/src/Hakyll/Web/Template/Read/Hakyll.hs b/src/Hakyll/Web/Template/Read/Hakyll.hs
index e0e10f4..fecf772 100644
--- a/src/Hakyll/Web/Template/Read/Hakyll.hs
+++ b/src/Hakyll/Web/Template/Read/Hakyll.hs
@@ -19,17 +19,17 @@ readTemplate = Template . readTemplate'
| "$$" `isPrefixOf` string =
Escaped : readTemplate' (drop 2 string)
| "$" `isPrefixOf` string =
- case readIdentifier (drop 1 string) of
- Just (key, rest) -> Identifier key : readTemplate' rest
+ case readKey (drop 1 string) of
+ Just (key, rest) -> Key key : readTemplate' rest
Nothing -> Chunk "$" : readTemplate' (drop 1 string)
| otherwise =
let (chunk, rest) = break (== '$') string
in Chunk chunk : readTemplate' rest
- -- Parse an identifier into (identifier, rest) if it's valid, and return
+ -- Parse an key into (key, rest) if it's valid, and return
-- Nothing otherwise
- readIdentifier string =
- let (identifier, rest) = span isAlphaNum string
- in if not (null identifier) && "$" `isPrefixOf` rest
- then Just (identifier, drop 1 rest)
+ readKey string =
+ let (key, rest) = span isAlphaNum string
+ in if not (null key) && "$" `isPrefixOf` rest
+ then Just (key, drop 1 rest)
else Nothing
diff --git a/src/Hakyll/Web/Template/Read/Hamlet.hs b/src/Hakyll/Web/Template/Read/Hamlet.hs
index 55b73f8..7b496de 100644
--- a/src/Hakyll/Web/Template/Read/Hamlet.hs
+++ b/src/Hakyll/Web/Template/Read/Hamlet.hs
@@ -35,7 +35,7 @@ fromHamletRT (HamletRT sd) = Template $ map fromSimpleDoc sd
where
fromSimpleDoc :: SimpleDoc -> TemplateElement
fromSimpleDoc (SDRaw chunk) = Chunk chunk
- fromSimpleDoc (SDVar [var]) = Identifier var
+ fromSimpleDoc (SDVar [var]) = Key var
fromSimpleDoc (SDVar _) = error
"Hakyll.Web.Template.Read.Hamlet.fromHamletRT: \
\Hakyll does not support '.' in identifier names when using \