>
> In a web2py application I generate .vcf and .ics files using web2py's 
> templating features. The problem is that all the code in {{}} results in 
> empty lines, which is no problem on my Mac, but Google doesn't allow empty 
> lines. For example, this: 
>
> {{response.headers['Content-Disposition'] = 'attachment;filename=%s.vcf' % 
> IS_SLUG()(organization.name)[0]}}BEGIN:VCARD
> VERSION:4.0
> {{if organization:}}
> FN: {{=organization.name}}
> ORG: {{=organization.name}}
> {{pass}}
>

You could do:

{{if organization:}}FN: {{=organization.name}}
ORG: {{=organization.name}}{{pass}}

and you won't get any blank lines when there is an organization, but I 
think you'll still get two blank lines when there is no organization.

Another option might be to render the response in the controller and then 
remove any blank lines from the text:

def make_vcard():
    data = [code to generate vcard data]
    vcard = response.render(context=dict(data=data))
    return vcard.replace('\n\n', '\n')

Anthony

Reply via email to