Saturday, November 05, 2005

Backbase and Yaws

The other night I was trying to get Backbase to work using the Yaws webserver. This in itself is trivial since the Backbase community edition is just a set of files that are served up by any webserver. The main difficulty I was striking was using the dynamic HTML generation of Yaws to generate the Backbase XHTML code - which uses elements and attributes with a special namespace prefixed to them.

Yaws has an 'ehtml' facility that works a bit like the various Lisp based S-Expression HTML libraries. The following code in a Yaws dynamic file:
out(A) ->
{ehtml, {p, [], "hello"}}.

generates:
<p>hello</p>

I struck a problem using DIV's though:
  {ehtml, {div, [], "hello"}}.
** 1: syntax error before: 'div' **

This is because 'div' is an infix operator in Erlang:
 1000 div 10.
=> 100

Similar problems occurred if I tried to use namespace prefixed elements and attributes. The solution for both cases, thanks to the Yaws mailing list, was to place these problematic symbols in single quotes:
  {ehtml, {'div', [], "hello"}}.
{ehtml, {'b:form', [{'b:destination', "URL"}], "Form Stuff"}}.


Categories: , ,

0 Comments:

Post a Comment

<< Home