diff --git a/TODO.md b/TODO.md index c02cfb4..401b7d5 100644 --- a/TODO.md +++ b/TODO.md @@ -3,6 +3,7 @@ - https://github.com/wereHamster/haskell-css-syntax - JS - Doing our own tokenizer lol +- [ ] swap from using `draft` to using `date` for determing draft status, lack of date = draft - [ ] setup fingerprinting in file names for css and js - setup lambdas via: https://hackage-content.haskell.org/package/mustache-2.4.3.1/docs/Text-Mustache.html#v:overText - This may require a refactor of how we handle templates to use `object` instead of just using aeson integration from the mustache crate diff --git a/src/Templates.hs b/src/Templates.hs index 5493b66..c4a2951 100644 --- a/src/Templates.hs +++ b/src/Templates.hs @@ -2,6 +2,7 @@ module Templates where import Data.Aeson (ToJSON) import qualified Data.Aeson as A +import Data.HashMap.Strict (insert) import Data.Text (Text) import qualified Data.Text as T import Development.Shake @@ -11,9 +12,13 @@ import GHC.Stack (HasCallStack) import Text.Mustache (ToMustache) import qualified Text.Mustache as Mus import qualified Text.Mustache.Compile as Mus +import qualified Text.Mustache.Types as Mus import Types (Post (postAuthor, postContent, postDate, postDescription, postLink, postTags, postTitle), RenderedPost (RenderedPost, rPostAuthor, rPostContent, rPostDate, rPostHasTags, rPostId, rPostIsoDate, rPostLink, rPostSummary, rPostTags, rPostTitle)) import Utilities +extend_with_lambda :: Mus.Object -> (Text, (Text -> Text)) -> Mus.Value +extend_with_lambda obj (key, val) = Mus.Object $ insert key (Mus.overText val) obj + applyTemplate :: (HasCallStack, (ToMustache a)) => String -> a -> Action Text applyTemplate templateName context = do tmpl <- readTemplate $ "templates" templateName