This plugin allows you to specify a renderer for per route. Here is an example
from bottle import Bottle
from bottle_renderer import RendererPlugin
app = Bottle()
renderer = RendererPlugin(template_context = {'FB_APP_ID': 1234}) # This will be available in templates
# You can override the renderers by specifying your own.
# renderer.add_renderer('json', your_json_renderer)
app.install(renderer)
app.uninstall('json') # no autojson
# to use in a route, just specify the "renderer" attribute
@app.get('/main', name='main', renderer='main.jinja2')
def get_main():
# do something
return ret_value
In your templates (jinja2, mako, etc.) you can access the following by default:
- R:
return value of the function
- app:
The current app
- request:
The current request
- response:
The current response
The following renderers are available:
@app.get(renderer='json', ..) # Renders return value as json @app.get(renderer='string', ..) # Renders return value as text/plain @app.get(renderer='<template_filename>.stpl', ..) # simple @app.get(renderer='<template_filename>.mako', ..) @app.get(renderer='<template_filename>.jinja2', ..) @app.get(renderer='<template_filename>.cheetah', ..) @app.get(renderer='<template_filename>.simpletal', ..)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bottle-renderer-0.1.tar.gz
(2.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bottle-renderer-0.1.tar.gz.
File metadata
- Download URL: bottle-renderer-0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf2ad07719a07dbc0f2403260e254425b474625a1617e999392ce0639f3b87a
|
|
| MD5 |
f7c8e061957ef27ec223a9007a5ef926
|
|
| BLAKE2b-256 |
5cb0768e3826067a7ec0ef2583d9cecd1f647381d6feaaded4f22d55761a97a4
|
File details
Details for the file bottle-renderer-0.1.macosx-10.6-universal.tar.gz.
File metadata
- Download URL: bottle-renderer-0.1.macosx-10.6-universal.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f03a51cb571db9f6f98a8f2ac546db806595ed31d5e2e1ddd1cc845b8e6f29
|
|
| MD5 |
1096b853df7c1906ebdbe264aabb4d4d
|
|
| BLAKE2b-256 |
43bec20388b60eab4147c6d2cf29ceba1c8c1183a8394a5fb21b532a3a1fa7ae
|