Fixed bug in inline templates

2 views
Skip to first unread message

Filippo Pacini

unread,
Mar 18, 2007, 4:48:04 AM3/18/07
to sgte - discussion
Hi all,
I found a bug in the rendering of inline map templates when in the
template was present a comma.

Commas are normally used inside map to separate different templates to
apply to data (e.g. if you want alternate color background in the row of
a table).
If you have a normal comma inside the map you have to escape it with a
backslash. This case was not handled properly.

I've integrated the fix both in the main trunk and in the TRY-yaws-tei
branch.

cheers,
filippo

etnt

unread,
Mar 21, 2007, 5:35:22 AM3/21/07
to sgte - A simple Erlang Template Engine
Hi,

I still have some problems with the comma character.
(Sorry if this mail ends up twice, I tried to send to the
mail addres, but it didn't seem to go through, so now
I'm doing a reply from within the group-page)

I'm trying ty expand the following:

$map:{"#$owner$": function(t) {save_owner("$owner$"\,t.id);}\,} owners
$

But I get:

"#tobbe": function(t) {save_owner("tobbe",t.id);}\"#bill": function(t)
{save_owner("bill",t.id);}\

and if i change to:

$map:{"#$owner$": function(t) {save_owner("$owner$"\,t.id);},} owners$

then I get:

"#tobbe": function(t) {save_owner("tobbe",t.id);}"#bill": function(t)
{save_owner("bill",t.id);}

The correct ouput that i do want to get is:

"#tobbe": function(t) {save_owner("tobbe",t.id);},"#bill": function(t)
{save_owner("bill",t.id);}

So:

1. Perhaps ',' is not a good character to have a SGTE meaning.
(since it often is used in javascript)

2. Perhaps a 'mapj' (map-join) would be nice, to get rid of the last
',' character.

Cheers, Tobbe

Filippo Pacini

unread,
Mar 21, 2007, 8:29:25 AM3/21/07
to etnt, sgte - A simple Erlang Template Engine
hi,

etnt wrote:
> Hi,
>
> I still have some problems with the comma character.
> (Sorry if this mail ends up twice, I tried to send to the
> mail addres, but it didn't seem to go through, so now
> I'm doing a reply from within the group-page)

Strange I'll take a look at the log files on the server.

> ... snip ...
Yes I still have a bug with commas.

>
> So:
>
> 1. Perhaps ',' is not a good character to have a SGTE meaning.
> (since it often is used in javascript)

Yes it was really a bad choice.

>
> 2. Perhaps a 'mapj' (map-join) would be nice, to get rid of the last
> ',' character.

What do you mean with mapj? a map and then a join passing a character?
Something like $mapj someTmpl attrList joinChar$?

I was already planning a mapList to map on a list of values. What do you
think about this solution?
- map as it should work now
- mapl to map on list of values
- mmap to map over multiple templates using a different separator from ','

Meanwhile, since you don't use multiple templates, attached there's a
modified version you can use. remove the escape before ',' and it should
work.

cheers,
filippo

sgte_tobbe.erl
Reply all
Reply to author
Forward
0 new messages