Skip to content

Instantly share code, notes, and snippets.

@efazati
Created January 4, 2013 10:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efazati/4451510 to your computer and use it in GitHub Desktop.
Save efazati/4451510 to your computer and use it in GitHub Desktop.
flask title decorator, set title easy and simple
from functools import wraps
def title(title=None):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
g.page_title = title
return f(*args, **kwargs)
return decorated_function
return decorator
@efazati
Copy link
Author

efazati commented Jan 4, 2013

just in base template set title some things like

<title>{{ site_name }}{% if g.page_title %} | {{ g.page_title }}{% endif %}</title>

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