diff --git a/conf/locale/babel.cfg b/conf/locale/babel.cfg index 6631586ad4..039ef1aa5f 100644 --- a/conf/locale/babel.cfg +++ b/conf/locale/babel.cfg @@ -15,6 +15,8 @@ input_encoding = utf-8 [mako: lms/templates/**.html] input_encoding = utf-8 +[mako: lms/templates/**.mustache] +input_encoding = utf-8 [mako: common/templates/**.html] input_encoding = utf-8 [mako: cms/templates/emails/**.txt] diff --git a/lms/djangoapps/django_comment_client/helpers.py b/lms/djangoapps/django_comment_client/helpers.py index 2a045d27fd..2d5f87ee19 100644 --- a/lms/djangoapps/django_comment_client/helpers.py +++ b/lms/djangoapps/django_comment_client/helpers.py @@ -1,6 +1,7 @@ from django.conf import settings from .mustache_helpers import mustache_helpers from functools import partial +from mako.template import Template from .utils import extend_content, merge_dict, render_mustache import django_comment_client.settings as cc_settings @@ -12,11 +13,21 @@ import os def include_mustache_templates(): mustache_dir = settings.PROJECT_ROOT / 'templates' / 'discussion' / 'mustache' - valid_file_name = lambda file_name: file_name.endswith('.mustache') - read_file = lambda file_name: (file_name, open(mustache_dir / file_name, "r").read()) - strip_file_name = lambda x: (x[0].rpartition('.')[0], x[1]) - wrap_in_tag = lambda x: "".format(x[0], x[1]) - file_contents = map(read_file, filter(valid_file_name, os.listdir(mustache_dir))) - return '\n'.join(map(wrap_in_tag, map(strip_file_name, file_contents))) + def is_valid_file_name(file_name): + return file_name.endswith('.mustache') + def read_file(file_name): + return open(mustache_dir / file_name, "r").read().decode('utf-8') + def template_id_from_file_name(file_name): + return file_name.rpartition('.')[0] + def process_mako(template_content): + return Template(template_content).render_unicode() + def make_script_tag(id, content): + return u"".format(id, content) + + return u'\n'.join( + make_script_tag(template_id_from_file_name(file_name), process_mako(read_file(file_name))) + for file_name in os.listdir(mustache_dir) + if is_valid_file_name(file_name) + ) diff --git a/lms/templates/discussion/_inline_new_post.html b/lms/templates/discussion/_inline_new_post.html index 370041866c..ae108a4d78 100644 --- a/lms/templates/discussion/_inline_new_post.html +++ b/lms/templates/discussion/_inline_new_post.html @@ -15,6 +15,7 @@ %endif %if is_course_cohorted: