Skip to main content

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', ..)

Metadata

Release files for bottle-renderer 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bottle-renderer 0.1.1
File Size Uploaded Provenance Actions
bottle-renderer-0.1.1.tar.gz 2.3 kB Without provenance Details for bottle-renderer-0.1.1.tar.gz

Release files / bottle-renderer-0.1.1.tar.gz

Download URL bottle-renderer-0.1.1.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fbe2809750f33e254169f7a55824a72e2c7bb367c1cb624ed9d56bc8ebc196cc
BLAKE2b-256 checksum
How to use checksums
eb9a24e27f8eabc7c3837ec599edb242c341a2837dfbc17ff9f7a78dd95485aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for bottle-renderer 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page