diff options
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Messages.hs')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Messages.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Messages.hs b/users/grfn/xanthous/src/Xanthous/Messages.hs index 2b1b3da1e8c1..985694139783 100644 --- a/users/grfn/xanthous/src/Xanthous/Messages.hs +++ b/users/grfn/xanthous/src/Xanthous/Messages.hs @@ -9,6 +9,7 @@ module Xanthous.Messages -- * Game messages , messages , render + , render_ , lookup , message , message_ @@ -17,7 +18,7 @@ module Xanthous.Messages import Xanthous.Prelude hiding (lookup) -------------------------------------------------------------------------------- import Control.Monad.Random.Class (MonadRandom) -import Data.Aeson (FromJSON, ToJSON, toJSON) +import Data.Aeson (FromJSON, ToJSON, toJSON, object) import qualified Data.Aeson as JSON import Data.Aeson.Generic.DerivingVia import Data.FileEmbed @@ -89,6 +90,10 @@ render msg params = do tpl <- resolve msg pure . toStrict . renderMustache tpl $ toJSON params +-- | Render a message with an empty set of params +render_ :: (MonadRandom m) => Message -> m Text +render_ msg = render msg $ object [] + lookup :: [Text] -> Message lookup path = fromMaybe notFound $ messages ^? ix path where notFound |