1

Digestive-functors-blaze creates html like <input type="text" id="foo" name="foo" /><label for="foo">Bar</label>, but I didn't find any standard way to for example add <br /> to the end.

I came up with this:

br :: (Monad m) => HappstackForm m H.Html BlazeFormHtml ()
br = Common.label $ \_ -> do
  createFormHtml $ \cfg -> do
    H.br

I can append it with <++ which does what I expect it to, but I wonder whether this is the intended way?

Also how would this extend with for example fieldsets.

cimmanon
  • 67,211
  • 17
  • 165
  • 171
Masse
  • 4,334
  • 3
  • 30
  • 41

1 Answers1

2

This is the intended way, although br would be a little cleaner when written as:

br :: Monad m
   => Form m i e BlazeFormHtml ()
br = view $ createFormHtml $ const H.br

Anyway, I figured this definition is a little cumbersome so I added a viewHtml function to Text.Digestive.Forms.Html:

viewHtml :: Monad m => a -> Form m i e (FormHtml a) ()
viewHtml = view . createFormHtml . const

This is available in digestive-functors-0.1.0.1. Using this new combinator, you should be able to just use <++ viewHtml H.br — I hope this helps.

jaspervdj
  • 893
  • 6
  • 7
  • Thank you. I'll try to see how fieldsets work and I'll mark this as an answer afterwards – Masse Jun 28 '11 at 11:06