mirror of
https://github.com/Xevion/runnerspace.git
synced 2026-01-31 12:25:51 -06:00
Add pluralizing macro filter to templating engine
- Only some plural edits are included here - some are locked behind commits coming soon™️
- Also made index template statistics variables read better
- Fixed spelling error in CSRF Error template rendering (hadn't hit the page yet)
This commit is contained in:
@@ -58,7 +58,7 @@ def create_app():
|
||||
|
||||
@app.errorhandler(CSRFError)
|
||||
def handle_csrf_error(e):
|
||||
return render_template('errprs/csrf.html', reason=e.description), 400
|
||||
return render_template('errors/csrf.html', reason=e.description), 400
|
||||
|
||||
@app.before_request
|
||||
def update_last_seen():
|
||||
@@ -68,6 +68,13 @@ def create_app():
|
||||
db.session.add(current_user)
|
||||
db.session.commit()
|
||||
|
||||
@app.template_filter('pluralize')
|
||||
def pluralize(number, singular='', plural='s'):
|
||||
if number == 1:
|
||||
return singular
|
||||
else:
|
||||
return plural
|
||||
|
||||
@app.context_processor
|
||||
def inject():
|
||||
return dict(now=datetime.utcnow)
|
||||
|
||||
Reference in New Issue
Block a user