Rewrite to support Flask-Theme