Re: HSP and document fragments

2 views
Skip to first unread message

Jeremy Shaw

unread,
Nov 3, 2010, 5:26:02 PM11/3/10
to ha...@googlegroups.com, haskell-se...@googlegroups.com

On Nov 3, 2010, at 2:45 PM, Gracjan Polak wrote:

> Hi all,
>
> In practice quite often I feel a need for document fragments, the
> inside of an element, of type GenChildList m.
>
> Currently I see only one way of doing this:
>
> asChild [ <% "literal text" %>, <% foo %>, <% bar + 5 %>]

Yeah, that is one way. I often end up adding dummy div or span tags:

<div>
literal text
<% foo %>
<% bar + 5 %>
</div>

But I never feel great about it :) (The type is not quite the same,
that produces an element instead of a list of children, but both of
those things can be embedded in a parent element, so it usually is
sufficient). Adding the div tags can be problematic if the divs have
non-zero margin/padding, since it affects layout.

> I imagine there should be something like this possible:
>
> <%>
> literal text
> <% foo %>
> <% bar + 5 %>
> </%>

Yes, that certainly seems nicer. I have copied my reply to the haskell-
server-pages group. That is probably a better place to ask about this.

http://groups.google.com/group/haskell-server-pages

Niklas should be able to give an idea of how feasible that is. The
good part is that the change would not require any modifications to
the XMLGen class or the XML type. It just requires the trhsx
preprocessor to learn a new special token and way to expand things. I
don't know how hard/easy that is.

- jeremy

Niklas Broberg

unread,
Nov 4, 2010, 4:30:00 AM11/4/10
to haskell-se...@googlegroups.com
> Niklas should be able to give an idea of how feasible that is. The good part
> is that the change would not require any modifications to the XMLGen class
> or the XML type. It just requires the trhsx preprocessor to learn a new
> special token and way to expand things. I don't know how hard/easy that is.

It's definitely feasible, though apart from changing trhsx it also
requires some 'major' changes in HSE. That said - I really like this
proposal. It's both simple and elegant, and doesn't interfere with
anything else. I will try to find the time to implement it Some Time
Soon (tm). :-)

Cheers,

/Niklas

Niklas Broberg

unread,
Nov 17, 2010, 5:20:12 AM11/17/10
to haskell-se...@googlegroups.com, ha...@googlegroups.com
>> I imagine there should be something like this possible:
>>
>> <%>
>>  literal text
>>  <% foo %>
>>  <% bar + 5 %>
>> </%>

I've now implemented this feature in haskell-src-exts 1.10.0 and hsx
0.8.0. Neither has been released on hackage yet, since a) I would
appreciate some testing by you guys before I do so, to see I haven't
broken anything, and b) I have a few other fixes/changes saved up for
the major version bump of HSE that I want to have a look at before
releasing it. But the changes are pushed to the respective darcs
repos, so please test away! :-)

Cheers,

/Niklas

Jeremy Shaw

unread,
Nov 17, 2010, 11:16:37 AM11/17/10
to haskell-se...@googlegroups.com
Nice.

Does other fixes/changes include a patch for this:

http://groups.google.com/group/haskell-server-pages/browse_thread/thread/250f9fd18858a219

I have a fair bit of HSP code that will not compile with out that
patch. And there is no work around except to edit Trhsx.hs and add
ExplicitForall (or fix Trhsx the 'right' way).

I am about to start documenting HSP in the happstack crash course. It
would be nice to get that resolved.

- jeremy

Niklas Broberg

unread,
Nov 18, 2010, 4:44:30 AM11/18/10
to haskell-se...@googlegroups.com
Ah, yeah, that's a bit embarrassing, it's been a while since you
flagged it to my attention. I'll make sure to fix that (in HSE, where
the real error is) in the release, yes.

Cheers,

/Niklas

> --
> You received this message because you are subscribed to the Google Groups "Haskell Server Pages" group.
> To post to this group, send email to haskell-se...@googlegroups.com.
> To unsubscribe from this group, send email to haskell-server-p...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/haskell-server-pages?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages