Cloned DMOJ
This commit is contained in:
parent
f623974b58
commit
49dc9ff10c
513 changed files with 132349 additions and 39 deletions
36
judge/jinja2/__init__.py
Normal file
36
judge/jinja2/__init__.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import itertools
|
||||
import json
|
||||
|
||||
from django.utils.http import urlquote
|
||||
from jinja2.ext import Extension
|
||||
from mptt.utils import get_cached_trees
|
||||
from statici18n.templatetags.statici18n import inlinei18n
|
||||
|
||||
from judge.highlight_code import highlight_code
|
||||
from judge.user_translations import gettext
|
||||
from . import (camo, datetime, filesize, gravatar, language, markdown, rating, reference, render, social,
|
||||
spaceless, submission, timedelta)
|
||||
from . import registry
|
||||
|
||||
registry.function('str', str)
|
||||
registry.filter('str', str)
|
||||
registry.filter('json', json.dumps)
|
||||
registry.filter('highlight', highlight_code)
|
||||
registry.filter('urlquote', urlquote)
|
||||
registry.filter('roundfloat', round)
|
||||
registry.function('inlinei18n', inlinei18n)
|
||||
registry.function('mptt_tree', get_cached_trees)
|
||||
registry.function('user_trans', gettext)
|
||||
|
||||
|
||||
@registry.function
|
||||
def counter(start=1):
|
||||
return itertools.count(start).__next__
|
||||
|
||||
|
||||
class DMOJExtension(Extension):
|
||||
def __init__(self, env):
|
||||
super(DMOJExtension, self).__init__(env)
|
||||
env.globals.update(registry.globals)
|
||||
env.filters.update(registry.filters)
|
||||
env.tests.update(registry.tests)
|
Loading…
Add table
Add a link
Reference in a new issue