Commits

Anonymous committed 079c537

always give style and css to the templater

  • Participants
  • Parent commits b1c74de
  • Branches lodgeit

Comments (0)

Files changed (3)

File lodgeit/controllers/pastes.py

 from lodgeit.utils import render_to_response
 from lodgeit.models import Paste
 from lodgeit.database import db
-from lodgeit.lib.highlighting import list_languages, STYLES, get_style
+from lodgeit.lib.highlighting import list_languages, STYLES
 from lodgeit.lib.pagination import generate_pagination
 from lodgeit.lib.captcha import check_hashed_solution, Captcha
 
         if raw:
             return Response(paste.code, mimetype='text/plain; charset=utf-8')
 
-        style, css = get_style(local.request)
         return render_to_response('show_paste.html',
             paste=paste,
-            style=style,
-            css=css,
             styles=STYLES,
             linenos=linenos,
         )
         return render_to_response('show_all.html',
             pastes=pastes,
             pagination=generate_pagination(page, 10, query.count(), link),
-            css=get_style(local.request)[1],
             show_personal='show_personal' in form_args
         )
 

File lodgeit/lib/highlighting.py

 
 from lodgeit import local
 from lodgeit.i18n import lazy_gettext as _
-from lodgeit.utils import render_template
 from lodgeit.lib.diff import prepare_udiff
 from lodgeit.lib.compilerparser import parse_gcc_messages, \
      parse_javac_messages
 
 def highlight_diff(code, _linenos=True):
     """Highlights an unified diff."""
+    from lodgeit.utils import render_template
     diffs, info = prepare_udiff(code)
     if code and not diffs:
         # the diff was quite very much malformatted.
 
 def format_compiler_messages(lines, compiler):
     """Highlights compiler messages."""
+    from lodgeit.utils import render_template
     return render_template('utils/compiler-messages.html',
                            lines=lines, compiler=compiler)
 

File lodgeit/utils.py

 
 from lodgeit import local
 from lodgeit.i18n import get_translations
+from lodgeit.lib.highlighting import get_style
 
 try:
     from hashlib import sha1
 
 def render_template(template_name, **context):
     request = local.request
+    style, css = get_style(request)
     context.update(
         request=request,
         gettext=request.translations.ugettext,
-        ngettext=request.translations.ungettext
+        ngettext=request.translations.ungettext,
+        style = style,
+        css = css,
     )
     return jinja_environment.get_template(template_name).render(context)