Skip to content

Commit

Permalink
Merge pull request #1716 from narrative/master
Browse files Browse the repository at this point in the history
Give mustache templates access to a 'year' tag
  • Loading branch information
mgsloan committed Jan 30, 2016
2 parents 2f8f6a4 + 385f737 commit 459d649
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Stack/New.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Text.IO as T
import qualified Data.Text.Lazy as LT
import Data.Time.Calendar
import Data.Time.Clock
import Data.Typeable
import Network.HTTP.Client.Conduit hiding (path)
import Network.HTTP.Download
Expand Down Expand Up @@ -176,9 +178,14 @@ applyTemplate
-> m (Map (Path Abs File) LB.ByteString)
applyTemplate project template nonceParams dir templateText = do
config <- asks getConfig
let context = M.union (M.union nonceParams name) configParams
currentYear <- do
now <- liftIO getCurrentTime
(year, _, _) <- return $ toGregorian . utctDay $ now
return $ T.pack . show $ year
let context = M.union (M.union nonceParams extraParams) configParams
where
name = M.fromList [("name", packageNameText project)]
extraParams = M.fromList [ ("name", packageNameText project)
, ("year", currentYear) ]
configParams = configTemplateParams config
(applied,missingKeys) <-
runWriterT
Expand Down

0 comments on commit 459d649

Please sign in to comment.