Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give mustache templates access to a 'year' tag #1716

Merged
merged 1 commit into from
Jan 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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