Move markup helpers to djangolib
This commit is contained in:
@@ -12,7 +12,7 @@ from contentstore.views.helpers import xblock_studio_url, xblock_type_display_na
|
||||
from openedx.core.djangolib.js_utils import (
|
||||
dump_js_escaped_json, js_escaped_string
|
||||
)
|
||||
from util.markup import HTML, ugettext as _
|
||||
from openedx.core.djangolib.markup import HTML, ugettext as _
|
||||
%>
|
||||
<%block name="title">${xblock.display_name_with_default_escaped} ${xblock_type_display_name(xblock) | h}</%block>
|
||||
<%block name="bodyclass">is-signedin course container view-container</%block>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%! from util.markup import ugettext as _ %>
|
||||
<%! from openedx.core.djangolib.markup import ugettext as _ %>
|
||||
<%page expression_filter="h"/>
|
||||
% for course_msg in course_enrollment_messages:
|
||||
<div class="wrapper-msg urgency-high">
|
||||
|
||||
@@ -16,12 +16,12 @@ def ugettext(text):
|
||||
|
||||
Use like this in Mako::
|
||||
|
||||
<% from util.markup import ugettext as _ %>
|
||||
<% from openedx.core.djangolib.markup import ugettext as _ %>
|
||||
<p>${_("Hello, world!")}</p>
|
||||
|
||||
Or with formatting::
|
||||
|
||||
<% from util.markup import HTML, ugettext as _ %>
|
||||
<% from openedx.core.djangolib.markup import HTML, ugettext as _ %>
|
||||
${_("Write & send {start}email{end}").format(
|
||||
start=HTML("<a href='mailto:ned@edx.org'>"),
|
||||
end=HTML("</a>"),
|
||||
@@ -41,7 +41,7 @@ def HTML(html): # pylint: disable=invalid-name
|
||||
|
||||
Use this when formatting HTML into other strings::
|
||||
|
||||
<% from util.markup import HTML, ugettext as _ %>
|
||||
<% from openedx.core.djangolib.markup import HTML, ugettext as _ %>
|
||||
${_("Write & send {start}email{end}").format(
|
||||
start=HTML("<a href='mailto:ned@edx.org'>"),
|
||||
end=HTML("</a>"),
|
||||
@@ -1,14 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Tests for util.markup
|
||||
Tests for openedx.core.djangolib.markup
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import ddt
|
||||
from mako.template import Template
|
||||
|
||||
from edxmako.template import Template
|
||||
from util.markup import escape, HTML, ugettext as _, ungettext
|
||||
from openedx.core.djangolib.markup import escape, HTML, ugettext as _, ungettext
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@@ -54,12 +54,12 @@ class FormatHtmlTest(unittest.TestCase):
|
||||
# The default_filters used here have to match the ones in edxmako.
|
||||
template = Template(
|
||||
"""
|
||||
<%! from util.markup import HTML, ugettext as _ %>
|
||||
<%! from openedx.core.djangolib.markup import HTML, ugettext as _ %>
|
||||
${_(u"A & {BC}").format(BC=HTML("B & C"))}
|
||||
""",
|
||||
default_filters=['decode.utf8', 'h'],
|
||||
)
|
||||
out = template.render({})
|
||||
out = template.render()
|
||||
self.assertEqual(out.strip(), u"A & B & C")
|
||||
|
||||
def test_ungettext(self):
|
||||
Reference in New Issue
Block a user