1 Dec 2011 22:48
Static files in Bottle with Mako
Matthew Dreon <matthew <at> dreon.org>
2011-12-01 21:48:33 GMT
2011-12-01 21:48:33 GMT
I currently reference my static files this way:
<at> app.get('/_static/<url:path>', name='static')
def serve_static(url):
path = "%s\\_static\\" % (os.getcwd())
return static_file(url, root=path)
I'd like to combine this with the get_url function so that I can
create relative paths throughout the structure of my site. This
stackoverflow post describes much of what I'm doing:
http://stackoverflow.com/questions/6978603/how-to-load-a-javascript-or-css-file-into-a-bottlepy-template
However, I don't understand what the additional route does:
<at> route('/')
<at> view('index')
def index():
return { 'get_url': get_url }
and I have not been able to get Mako to understand a call to Bottle.
I would imagine it would be something like this in the template code:
<% app.get_url('static', '/css/main.css') %>" but that results in
AttributeError: 'Undefined' object has no attribute 'get_url'.
Any help would be appreciated.
RSS Feed