[erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way?

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Wed Nov 23 21:31:28 CET 2011


I took a harder look at mochiweb after I sent my first mail thinking that I
might have forgotten something and sure enough all the building blocks were
there.

I guess that I am still ending up on wrong side of this. Implementing yet
another module with the transformations I want. Sooner or later I will
throw it away because it has become to bloated and I want something leaner.
.. *repeat*  Sounds familiar.

Another problem is that I don't really want to have lots of dependencies
for an escript, but that is a whole other BoW.

// Björn-Egil


2011/11/23 Bob Ippolito <bob@REDACTED>

> I wouldn't say that mochiweb_html has good support for transforms, but
> it's easy enough to build that stuff.
>
> mochiweb isn't a framework, it's just a collection of libraries that we
> use. mochiweb_html is mostly self-contained although it depends on another
> module or two full of relevant constants.
>
> -bob
>
>
> On Wednesday, November 23, 2011, Daniel Dormont <dan@REDACTED>
> wrote:
> > I've had decent luck with mochiweb_html so far. It doesn't require the
> > full mochiweb framework (though it's not totally self contained - some
> > of the other modules are needed). Check out mochiweb:to_html, which
> > does require a data structure somewhat different from what you have in
> > your render function but might work.
> >
> > dan
> >
> > 2011/11/22 Björn-Egil Dahlberg <wallentin.dahlberg@REDACTED>:
> >> I am frequently in a position where I render html output from logs or
> >> dynamically render erlang data to html in a server.
> >> Usually I don't use any lib for this but rather do something like,
> >>
> >> render({Tag, Data}) ->
> >>     T = atom_to_binary(Tag, utf8),
> >>     [ <<"<",T/binary,">">>, render(Data),<<"</",T/binary,">">>];
> >> render(I) when is_integer(I) -> I;
> >> render(Data) when is_binary(Data) -> quote(Data).
> >> render([I|Is]) -> [render(I) | render(Is)];
> >> render([]) -> [].
> >> and put an io:put_chars([render(Data)]) somewhere.
> >> This is of course simple enough but does not cover all bases nor does it
> >> feel right. =)
> >> In other cases I would like an html file where I can embed tags (like
> ruby
> >> on rails or yaws) and substitute the tags for my input.
> >> Mind you, I just want my iolist. I do *not* want a framework which sets
> up
> >> dispatchers, sockets, handlers and what not. I just want an easy way,
> from
> >> erlang, to describe html strings or rewrite a template file (or
> string). In
> >> the template some javascripts and headers are usually defined while the
> body
> >> or some content div should be substituted. Well, I think you get it.
> >> Now which library should I use if I want a lean, clean syntax in my
> module.
> >> Or, put in another way: "Maximal html expressability with minimal erlang
> >> verbosity."
> >> What should I use?
> >> // Björn-Egil
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >>
> >>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111123/044bb3d6/attachment.htm>


More information about the erlang-questions mailing list