shakespeare 2.0.10 → 2.0.11
raw patch · 4 files changed
+47/−1 lines, 4 files
Files
- ChangeLog.md +4/−0
- Text/Hamlet.hs +2/−0
- Text/TypeScript.hs +40/−0
- shakespeare.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+### 2.0.11++* Export hamletFromString [#191](https://github.com/yesodweb/shakespeare/pull/191)+ ### 2.0.10 * Added `ixhamlet` [#177](https://github.com/yesodweb/shakespeare/pull/177)
Text/Hamlet.hs view
@@ -44,6 +44,8 @@ , maybeH , asHtmlUrl , attrsToHtml+ -- * low-level+ , hamletFromString ) where import Text.Shakespeare.Base
Text/TypeScript.hs view
@@ -58,11 +58,15 @@ -- | These QuasiQuoter and Template Haskell methods return values of -- type @'JavascriptUrl' url@. See the Yesod book for details. tsc+ , tscJSX , typeScriptFile+ , typeScriptJSXFile , typeScriptFileReload+ , typeScriptJSXFileReload #ifdef TEST_EXPORT , typeScriptSettings+ , typeScriptJSXSettings #endif ) where @@ -93,6 +97,17 @@ } } ++-- | Identical to 'typeScriptSettings' but uses jsx when compiling TypeScript+typeScriptJSXSettings :: Q ShakespeareSettings+typeScriptJSXSettings = do+ tsSettings <- typeScriptSettings+ let rp = ReadProcess "sh" ["-c", "TMP_IN=$(mktemp XXXXXXXXXX.tsx); TMP_OUT=$(mktemp XXXXXXXXXX.js); cat /dev/stdin > ${TMP_IN} && tsc --module amd --jsx react --out ${TMP_OUT} ${TMP_IN} && cat ${TMP_OUT}; rm ${TMP_IN} && rm ${TMP_OUT}"]+ return $ tsSettings {+ preConversion = fmap (\pc -> pc { preConvert = rp }) (preConversion tsSettings)+ }++ -- | Read inline, quasiquoted TypeScript tsc :: QuasiQuoter tsc = QuasiQuoter { quoteExp = \s -> do@@ -100,6 +115,13 @@ quoteExp (shakespeare rs) s } +-- | Read inline, quasiquoted TypeScript with jsx+tscJSX :: QuasiQuoter+tscJSX = QuasiQuoter { quoteExp = \s -> do+ rs <- typeScriptJSXSettings+ quoteExp (shakespeare rs) s+ }+ -- | Read in a TypeScript template file. This function reads the file once, at -- compile time. typeScriptFile :: FilePath -> Q Exp@@ -107,10 +129,28 @@ rs <- typeScriptSettings shakespeareFile rs fp +-- | Read in a TypeScript template file with jsx. This function reads the file+-- once, at compile time.+typeScriptJSXFile :: FilePath -> Q Exp+typeScriptJSXFile fp = do+ rs <- typeScriptJSXSettings+ shakespeareFile rs fp+++ -- | Read in a TypeScript template file. This impure function uses -- unsafePerformIO to re-read the file on every call, allowing for rapid -- iteration. typeScriptFileReload :: FilePath -> Q Exp typeScriptFileReload fp = do rs <- typeScriptSettings+ shakespeareFileReload rs fp+++-- | Read in a TypeScript with jsx template file. This impure function uses+-- unsafePerformIO to re-read the file on every call, allowing for rapid+-- iteration.+typeScriptJSXFileReload :: FilePath -> Q Exp+typeScriptJSXFileReload fp = do+ rs <- typeScriptJSXSettings shakespeareFileReload rs fp
shakespeare.cabal view
@@ -1,5 +1,5 @@ name: shakespeare-version: 2.0.10+version: 2.0.11 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>