Skip to content

Instantly share code, notes, and snippets.

@yogsototh
Last active December 18, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogsototh/5815082 to your computer and use it in GitHub Desktop.
Save yogsototh/5815082 to your computer and use it in GitHub Desktop.
Serve javascript
> newtype RepJavascript = RepJavascript Content
> instance ToTypedContent RepJavascript where
> toTypedContent (RepJavascript c) = TypedContent typeJavascript c
> instance HasContentType RepJavascript where
> getContentType _ = typeJavascript
> deriving instance ToContent RepJavascript
> deriving instance ToContent Javascript where
> toContent = toContent . renderJavascript
>
> juliusToRepJavascript j = do
> render <- getUrlRenderParams
> return $ toTypedContent $ RepJavascript (toContent $ j render)
> sendJavascriptFromAction :: Action -> Handler TypedContent
> sendJavascriptFromAction action = do
> juliusToRepJavascript $(juliusFile "templates/action.julius")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment