Skip to content

Instantly share code, notes, and snippets.

@j2labs
Last active December 30, 2015 15:29
Show Gist options
  • Save j2labs/7848611 to your computer and use it in GitHub Desktop.
Save j2labs/7848611 to your computer and use it in GitHub Desktop.
A Brubeck demo showing how Jinja2 support works with the new plugin system.
#!/usr/bin/env python
from brubeck.servers.web import WebServer
from brubeck.handlers.web import WebMessageHandler
from brubeck.connections import WSGIConnection
from brubeck_templates.plugins import Jinja2Plugin
import sys
class DemoHandler(WebMessageHandler):
def get(self):
name = self.get_argument('name', 'dude')
body = self.plugins.jinja2.render('success.html', name=name)
return self.render(body=body)
app = WebServer(msg_conn=WSGIConnection(),
handlers=[(r'^/brubeck', DemoHandler)],
plugins=[Jinja2Plugin('./templates/jinja2')])
app.run()
@whitmo
Copy link

whitmo commented Dec 7, 2013

Have you looked at how plugins (aka includes) work in Pyramid?

@j2labs
Copy link
Author

j2labs commented Dec 7, 2013

No, that's a great idea. I looked at a few frameworks, but I always forget to check in with Pyramid too.

Thanks for suggesting it!

@j2labs
Copy link
Author

j2labs commented Dec 7, 2013

Mind hooking me up with a link for an example too? The docs are kinda dense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment