@@ -36,32 +36,9 @@
3636--
3737-- Because of it's simplicity, these templates can be used for more than HTML:
3838-- you could make, for example, CSS or JS templates as well.
39−--
40−-- In addition to the native format, Hakyll also supports hamlet templates. For
41−-- more information on hamlet templates, please refer to:
42−-- <http://hackage.haskell.org/package/hamlet>. Internally, hamlet templates are
43−-- converted to hakyll templates -- which means that you can only use variable
44−-- insertion (and not all hamlet's features).
45−--
46−-- This is an example of a valid hamlet template. You should place them in
47−-- files with a @.hamlet@ extension:
48−--
49−-- > !!!
50−-- > <html>
51−-- > <head>
52−-- > <meta charset="UTF-8">
53−-- > <title> MyAweSomeCompany - #{title}
54−-- > <body>
55−-- > <h1> MyAweSomeCompany - #{title}
56−-- > <div id="navigation">
57−-- > <a href="/index.html"> Home
58−-- > <a href="/about.html"> About
59−-- > <a href="/code.html"> Code
60−-- > #{body}
6139module Hakyll.Web.Template
6240 ( Template
6341 , templateCompiler
64− , templateCompilerWith
6542 , applyTemplate
6643 , applyTemplateWith
6744 ) where
@@ -70,14 +47,10 @@ module Hakyll.Web.Template
7047--------------------------------------------------------------------------------
7148import Control.Monad (forM, liftM)
7249import Prelude hiding (id)
73−import System.FilePath (takeExtension)
74−import Text.Hamlet (HamletSettings,
75− defaultHamletSettings)
7650
7751
7852--------------------------------------------------------------------------------
7953import Hakyll.Core.Compiler
80−import Hakyll.Core.Identifier
8154import Hakyll.Core.Item
8255import Hakyll.Web.Template.Context
8356import Hakyll.Web.Template.Internal
@@ -85,25 +58,11 @@ import Hakyll.Web.Template.Read
8558
8659
8760--------------------------------------------------------------------------------
88−-- | Read a template. If the extension of the file we're compiling is
89−-- @.hml@ or @.hamlet@, it will be considered as a Hamlet template, and parsed
90−-- as such.
61+-- | Read a template.
9162templateCompiler :: Compiler (Item Template)
92−templateCompiler = templateCompilerWith defaultHamletSettings
93−
94−
95−--------------------------------------------------------------------------------
96−-- | Version of 'templateCompiler' that enables custom settings.
97−templateCompilerWith :: HamletSettings -> Compiler (Item Template)
98−templateCompilerWith settings =
99− cached "Hakyll.Web.Template.templateCompilerWith" $ do
100− identifier <- getUnderlying
101− item <- getResourceString
102− if takeExtension (toFilePath identifier) `elem` [".hml", ".hamlet"]
103− -- Hamlet template
104− then return $ fmap (readHamletTemplateWith settings) item
105− -- Hakyll template
106− else return $ fmap readTemplate item
63+templateCompiler = cached "Hakyll.Web.Template.templateCompiler" $ do
64+ item <- getResourceString
65+ return $ fmap readTemplate item
10766
10867
10968--------------------------------------------------------------------------------