how to set syntax for simple template?

160 views
Skip to first unread message

Gianni Di Noia

unread,
Aug 30, 2013, 7:21:42 PM8/30/13
to bott...@googlegroups.com
I need to  change the default_syntax. For this reason I replace the row 3306 of dev branch from 
default_syntax = '<% %> % {{ }}'
to 
default_syntax = '<% %> % {^ ^}'

Works good but I see a set_syntax() in the code. How to use it for change the syntax from my app without modify bottle.py?

thanks,
Gianni

Marcel Hellkamp

unread,
Aug 31, 2013, 11:47:10 AM8/31/13
to bott...@googlegroups.com
import bottle, functools
MyAdapter = functools.partial(bottle.SimpleTemplate, syntax='<% %> % {^
^}'))
template = functools.partial(bottle.template, template_adapter=MyAdapter)

At a later point it will be possible to configure the templating system
via app.config settings.
> --
> --
> You are member of the "bottlepy" group at google groups.
> See http://groups.google.de/group/bottlepy for mailing list options.
> See http://bottlepy.org/ for news and documentation.
>
> ---
> You received this message because you are subscribed to the Google
> Groups "bottlepy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bottlepy+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Gianni Di Noia

unread,
Aug 31, 2013, 3:58:51 PM8/31/13
to bott...@googlegroups.com
Thank you Marcel.
the config file is a great idea: it keeps separate configs and code.
I see now the "Tell us what you think." on top of configuration page.
Little to say: the only issue I had going to bottle is this one.
The rest are all points in favor: autojson, secure cookies and routing
system are my favorites.
Nothing is missing in SimpleTemplate: Initially I was worried about
filters in template {{ value|filter }}, but {{ filter(value) }} I
think is better..
Peraphs, routing is missing a trailing slashes helper: I redirect
route without slash to same route with slash, but that's okay.

- Gianni
Reply all
Reply to author
Forward
0 new messages