chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] More thoughts on Ersatz


From: Peter Bex
Subject: Re: [Chicken-users] More thoughts on Ersatz
Date: Tue, 12 Mar 2013 20:11:57 +0100
User-agent: Mutt/1.4.2.3i

On Tue, Mar 12, 2013 at 07:04:54PM +0100, Moritz Heidkamp wrote:
> Hi Matt,
> 
> Matt Gushee <address@hidden> writes:
> > 3) {% if not loop.last %} also raises a parser error. This was a fairly
> > important feature for me, because I have a couple of templates that
> > generate JSON from arbitrary-length lists of objects, and there needs to be
> > a comma *between* the objects in JSON. So I was doing this:
> 
> This doesn't seem like a very good idea to me. You might generate
> invalid JSON if the values you pass into the template don't happen to
> have textual representations which also happen to be valid JSON values
> (if I understand the way Jinja works correctly here). I'd suggest using
> a proper JSON emitter like the one contained in medea
> (http://wiki.call-cc.org/eggref/4/medea) instead.

Not to sound like a broken record, but I'd add that this applies 100% to
HTML/XML as well.  I would suggest using SXML or something similar over
a string-based templating language.  This allows you to prevent
injection bugs as well as accidental mismatching of opening/closing tags.

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]