I am frequently in a position where I render html output from logs or dynamically render erlang data to html in a server.<div>Usually I don't use any lib for this but rather do something like,</div><div><br></div><div>
<br></div><div>render({Tag, Data}) -> </div><div> T = atom_to_binary(Tag, utf8),</div><div><div> [ <<"<",T/binary,">">>, render(Data),<<"</",T/binary,">">>];</div>
</div><div>render(I) when is_integer(I) -> I;</div><div>render(Data) when is_binary(Data) -> quote(Data).</div><div>render([I|Is]) -> [render(I) | render(Is)];</div><div>render([]) -> [].</div><div><br></div><div>
and put an io:put_chars([render(Data)]) somewhere.</div><div><br></div><div>This is of course simple enough but does not cover all bases nor does it feel right. =)</div><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>Now which library should I use if I want a lean, clean syntax in my module. </div><div>Or, put in another way: "Maximal html expressability with minimal erlang verbosity."</div><div><br></div>
<div>What should I use?</div><div><br></div><div>// Björn-Egil</div>