Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  Problems with ehtml

Guest
Posted: Wed May 14, 2008 6:19 pm Reply with quote
Guest
Hi All,
I have this code but I can't get the correct output in any way.
<erl>
out(A)
Rows=mydb:select_all(),
% Rows is a list and it has the following tructure:
% [{data, 1, "A1", "B1"}, {data, 2, "A2", "B2"},
% .., {data, n, "An", "Bn"}].
...
</erl>
The desired output is the following:
<p>
<ul>
<li>1</li>
<li>A1</li>
<li>B1</li>
</ul>
</p>
<p>
<ul>
<li>2</li>
<li>A2</li>
<li>B2</li>
</ul>
</p>
...
<p>
<ul>
<li>n</li>
<li>An</li>
<li>Bn</li>
</ul>
</p>

Any hint?
Thank you.

//JK


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist
Guest
Posted: Wed May 14, 2008 6:47 pm Reply with quote
Guest
I would do something like the following (assuming that the 'data' records
always have a fixed length):

<erl>
out(A) ->
Rows = [{data, 1, "A1", "A2"}, {data, 2, "B1", "B2"}, {data, 3, "C1",
"C2"} ],
{ehtml,
lists:map(fun ({data, Num, Val1, Val2}) ->
{p, [], {ul, [], [{li, [], integer_to_list(Num)},
{li, [], Val1},
{li, [], Val2}]}}
end, Rows)}.
</erl>


Dominique
<erl>
out(A) ->
Rows = [{data, 1, "A1", "A2"}, {data, 2, "B1", "B2"}, {data, 3, "C1",
"C2"} ],
{ehtml,
lists:map(fun ({data, Num, Val1, Val2}) ->
{p, [], {ul, [], [{li, [], integer_to_list(Num)},
{li, [], Val1}, {li, [], Val2}]}}
end, Rows)}.
</erl>
> From: erlyaws-list-bounces@lists.sourceforge.net [mailto:erlyaws-list-
> bounces@lists.sourceforge.net] On Behalf Of Jilani Khaldi
> Sent: May 14, 2008 2:11 PM
> To: YAWS ML
> Subject: [Erlyaws-list] Problems with ehtml
>
> Hi All,
> I have this code but I can't get the correct output in any way.
> <erl>
> out(A)
> Rows=mydb:select_all(),
> % Rows is a list and it has the following tructure:
> % [{data, 1, "A1", "B1"}, {data, 2, "A2", "B2"},
> % .., {data, n, "An", "Bn"}].
> ...
> </erl>
> The desired output is the following:
> <p>
> <ul>
> <li>1</li>
> <li>A1</li>
> <li>B1</li>
> </ul>
> </p>
> <p>
> <ul>
> <li>2</li>
> <li>A2</li>
> <li>B2</li>
> </ul>
> </p>
> ...
> <p>
> <ul>
> <li>n</li>
> <li>An</li>
> <li>Bn</li>
> </ul>
> </p>
>
> Any hint?
> Thank you.
>
> //JK
>
>
> -----------------------------------------------------------------------
> --
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum