shakespeare-js 0.11.0 → 0.11.0.1
raw patch · 2 files changed
+16/−3 lines, 2 files
Files
- Text/Coffee.hs +15/−2
- shakespeare-js.cabal +1/−1
Text/Coffee.hs view
@@ -39,6 +39,21 @@ import Text.Shakespeare import Text.Julius +-- | The Coffeescript language compiles down to Javascript.+-- Previously we waited until the very end, at the rendering stage to perform this compilation.+-- Lets call is a post-conversion+-- This had the advantage that all Haskell values were inserted first:+-- for example a value could be inserted that Coffeescript would compile into Javascript.+-- While that is perhaps a safer approach, the advantage is not used in practice:+-- it was that way mainly for ease of implementation.+-- The down-side is the template must be compiled down to Javascript during every request.+-- If instead we do a pre-conversion to compile down to Javascript,+-- we only need to perform the compilation once.+-- During the pre-conversion we first modify all Haskell insertions+-- so that they will be ignored by the Coffeescript compiler (backticks).+-- So %{var} is change to `%{var}` using the preEscapeBegin and preEscapeEnd.+-- preEscapeIgnore is used to not insert backtacks for variable already inside strings or backticks.+-- coffeescript will happily ignore the interpolations, and backticks would not be treated as escaping in that context. coffeeSettings :: Q ShakespeareSettings coffeeSettings = do jsettings <- javascriptSettings@@ -46,10 +61,8 @@ , preConversion = Just PreConvert { preConvert = ReadProcess "coffee" ["-epb"] , preEscapeBegin = "`"- -- ^ backticks means the Coffeescript compiler will pass-through to javascript. , preEscapeEnd = "`" , preEscapeIgnore = "'\"`"- -- ^ backticks are ignored inside a quote } }
shakespeare-js.cabal view
@@ -1,5 +1,5 @@ name: shakespeare-js-version: 0.11.0+version: 0.11.0.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>