@@ -36,32 +36,9 @@
37-- Because of it's simplicity, these templates can be used for more than HTML:
37-- Because of it's simplicity, these templates can be used for more than HTML:
38-- you could make, for example, CSS or JS templates as well.
38-- you could make, for example, CSS or JS templates as well.
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).
46−-- This is an example of a valid hamlet template. You should place them in
47−-- files with a @.hamlet@ extension:
52−-- > <meta charset="UTF-8">
53−-- > <title> MyAweSomeCompany - #{title}
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
61module Hakyll.Web.Template
39module Hakyll.Web.Template
62 ( Template
40 ( Template
63 , templateCompiler
41 , templateCompiler
64− , templateCompilerWith
65 , applyTemplate
42 , applyTemplate
66 , applyTemplateWith
43 , applyTemplateWith
@@ -70,14 +47,10 @@ module Hakyll.Web.Template
70--------------------------------------------------------------------------------
47--------------------------------------------------------------------------------
71import Control.Monad (forM, liftM)
48import Control.Monad (forM, liftM)
72import Prelude hiding (id)
49import Prelude hiding (id)
73−import System.FilePath (takeExtension)
74−import Text.Hamlet (HamletSettings,
75− defaultHamletSettings)
78--------------------------------------------------------------------------------
52--------------------------------------------------------------------------------
79import Hakyll.Core.Compiler
53import Hakyll.Core.Compiler
80−import Hakyll.Core.Identifier
81import Hakyll.Core.Item
54import Hakyll.Core.Item
82import Hakyll.Web.Template.Context
55import Hakyll.Web.Template.Context
83import Hakyll.Web.Template.Internal
56import Hakyll.Web.Template.Internal
@@ -85,25 +58,11 @@ import Hakyll.Web.Template.Read
87--------------------------------------------------------------------------------
60--------------------------------------------------------------------------------
88−-- | Read a template. If the extension of the file we're compiling is
61+-- | Read a template.
89−-- @.hml@ or @.hamlet@, it will be considered as a Hamlet template, and parsed
91templateCompiler :: Compiler (Item Template)
62templateCompiler :: Compiler (Item Template)
92−templateCompiler = templateCompilerWith defaultHamletSettings
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
63+templateCompiler = cached "Hakyll.Web.Template.templateCompiler" $ do
100− identifier <- getUnderlying
101− item <- getResourceString
64+ item <- getResourceString
102− if takeExtension (toFilePath identifier) `elem` [".hml", ".hamlet"]
104− then return $ fmap (readHamletTemplateWith settings) item
106− else return $ fmap readTemplate item
65+ return $ fmap readTemplate item
109--------------------------------------------------------------------------------
68--------------------------------------------------------------------------------