How do I load a plain html-formatted file (not a hamlet-formatted file) as a widget? In other words I'm looking for the html equivalent of:
toWidget $(whamletFile "test.hamlet")
How do I load a plain html-formatted file (not a hamlet-formatted file) as a widget? In other words I'm looking for the html equivalent of:
toWidget $(whamletFile "test.hamlet")
For this you use
sendFilein your handler function (see its definition)The first argument is the Mime Type while the second is the file path.
For example, you could code something like:
Here’s Another example. Say I have the following model:
The handler might look like:
Edit 2015-06-05
sendFileoperates at a low level whileaddScriptor$(widgetFile …)operates at a higher level.$(widgetFile …)uses TemplateHaskell to convert your Hamlet/Cassius/Lucius/Julius templates into actual Haskell source code before your project is compiled. The same applies similarly to[hamlet|…|].addScriptworks with aRoutewhilesendFileworks with aFilePath. This meansaddScriptwill be able to detect missing files at compile time.sendFilewill detect missing files at runtime.There are some tools to convert Html to Hamlet:
An equivalent of
addScriptfor Html files does not make sense:addScriptwill generate ascripttag to tell the browser to download an external resource. This does not apply to an Html file.