{-# LANGUAGE GeneralizedNewtypeDeriving #-}{-# LANGUAGE FlexibleInstances #-}{-# LANGUAGE CPP #-}{-# OPTIONS_GHC -fno-warn-missing-fields #-}-- | A Shakespearean module for Roy, introducing type-safe,-- compile-time variable and url interpolation. It is exactly the same as-- "Text.Julius", except that the template is first compiled to Javascript with-- the system tool @roy@.---- To use this module, @roy@ must be installed on your system.---- Unfortunately variable interpolation in Roy does not currently work,-- but it can with a small change to Roy:-- <https://github.com/pufuwozu/roy/issues/165>---- Further reading:---- 1. Shakespearean templates: <http://www.yesodweb.com/book/templates>---- 2. Roy: <http://http://roy.brianmckenna.org/>moduleText.Roy(-- * Functions-- ** Template-Reading Functions-- | These QuasiQuoter and Template Haskell methods return values of-- type @'JavascriptUrl' url@. See the Yesod book for details.roy,royFile,royFileReload#ifdef TEST_EXPORT,roySettings#endif)whereimportLanguage.Haskell.TH.Quote(QuasiQuoter(..))importLanguage.Haskell.TH.SyntaximportText.ShakespeareimportText.Julius-- | The Roy language compiles down to Javascript.-- We do this compilation once at compile time to avoid needing to do it during the request.-- We call this a preConversion because other shakespeare modules like Lucius use Haskell to compile during the request instead rather than a system call.roySettings::QShakespeareSettingsroySettings=dojsettings<-javascriptSettingsreturn$jsettings{varChar='#',preConversion=JustPreConvert{preConvert=ReadProcess"roy"["--stdio"],preEscapeIgnoreBalanced="'\"",preEscapeIgnoreLine="//",wrapInsertion=Nothing{-
Just WrapInsertion {
wrapInsertionIndent = Just " "
, wrapInsertionStartBegin = "(\\"
, wrapInsertionSeparator = " "
, wrapInsertionStartClose = " ->\n"
, wrapInsertionEnd = ")"
, wrapInsertionApplyBegin = " "
, wrapInsertionApplyClose = ")\n"
}
-}}}-- | Read inline, quasiquoted Roy.roy::QuasiQuoterroy=QuasiQuoter{quoteExp=\s->dors<-roySettingsquoteExp(shakespearers)s}-- | Read in a Roy template file. This function reads the file once, at-- compile time.royFile::FilePath->QExproyFilefp=dors<-roySettingsshakespeareFilersfp-- | Read in a Roy template file. This impure function uses-- unsafePerformIO to re-read the file on every call, allowing for rapid-- iteration.royFileReload::FilePath->QExproyFileReloadfp=dors<-roySettingsshakespeareFileReloadrsfp