1. new in this version
  2. build a web 2.0 app in happstack
  3. why happstack is cool
  4. getting started with happstack
  5. prerequisites
  6. cabal install me
  7. first shot at happstack
  8. url handling
  9. basic HTML inclusion
  10. templates
  11. stringtemplate basics
  12. debugging
  13. form data: get and post
  14. form data: file uploads
  15. cookies
  16. introduction to macid
  17. first steps with macid
  18. scaling with multimaster
  19. using macid safely
  20. macid dummy data
  21. changing the data model
  22. macid stress test
  23. limitations of macid
  24. foreign characters
  25. IxSets
  26. cron jobs
  27. thanks
  28. appendix (floundering in ghci)

Basic HTML inclusion

Happstack is completely agnostic as to the source of the HTML served. There is no required templating system. We'll be looking at a few simple ways to include HTML in your application:

  • HtmlString
  • Text.Html
  • HStringTemplate

HtmlString

We've already seen the use of HtmlString, from the happstack-helpers package, in the ControllerBasic.hs file. You can include your HTML as String literals wrapped with a HtmlString constructor and the ToMessage instance for HtmlString will take care of the rest.

Text.Html

I won't be providing a tutorial on using Text.Html, but I want to point out that there is a ToMessage instance for Html. This means that anything built from the combinators included in Text.Html will display correctly.

HStringTemplate

Lets move on to the next couple of chapters, which will cover the use HStringTemplate in some depth.