Ticket #16677: 16677.patch

File 16677.patch, 6.9 KB (added by aaugustin, 4 years ago)
  • django/templatetags/future.py

     
    1919
    2020        {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
    2121    """
    22     bits = token.contents.split()
     22    bits = token.split_contents()
    2323    parsed = False
    2424    if len(bits) not in (2, 3):
    2525        raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
  • tests/regressiontests/templates/tests.py

     
    508508    def get_template_tests(self):
    509509        # SYNTAX --
    510510        # 'template_name': ('template contents', 'context dict', 'expected string output' or Exception class)
    511         return {
     511        basedir = os.path.dirname(os.path.abspath(__file__))
     512        tests = {
    512513            ### BASIC SYNTAX ################################################
    513514
    514515            # Plain text should go through the template parser untouched
     
    13501351            ### SSI TAG ########################################################
    13511352
    13521353            # Test normal behavior
    1353             'old-ssi01': ('{%% ssi %s %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
    1354             'old-ssi02': ('{%% ssi %s %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''),
     1354            'old-ssi01': ('{%% ssi %s %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
     1355            'old-ssi02': ('{%% ssi %s %%}' % os.path.join(basedir, 'not_here'), {}, ''),
    13551356
    13561357            # Test parsed output
    1357             'old-ssi06': ('{%% ssi %s parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
    1358             'old-ssi07': ('{%% ssi %s parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
     1358            'old-ssi06': ('{%% ssi %s parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
     1359            'old-ssi07': ('{%% ssi %s parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
    13591360
    13601361            # Future compatibility
    13611362            # Test normal behavior
    1362             'ssi01': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
    1363             'ssi02': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''),
    1364             'ssi03': ("{%% load ssi from future %%}{%% ssi '%s' %%}" % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''),
     1363            'ssi01': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
     1364            'ssi02': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'not_here'), {}, ''),
     1365            'ssi03': ("{%% load ssi from future %%}{%% ssi '%s' %%}" % os.path.join(basedir, 'not_here'), {}, ''),
    13651366
    13661367            # Test passing as a variable
    1367             'ssi04': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'),
     1368            'ssi04': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': os.path.join(basedir, 'templates', 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'),
    13681369            'ssi05': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': 'no_file'}, ''),
    13691370
    13701371            # Test parsed output
    1371             'ssi06': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
    1372             'ssi07': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
     1372            'ssi06': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
     1373            'ssi07': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
    13731374
     1375            # Test space in file name
     1376            'ssi08': ('{%% load ssi from future %%}{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {}, 'This is for testing an ssi include with spaces in its name. {{ test }}\n'),
     1377            'ssi09': ('{%% load ssi from future %%}{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include with spaces in its name. Look ma! It parsed!\n'),
    13741378
    13751379            ### TEMPLATETAG TAG #######################################################
    13761380            'templatetag01': ('{% templatetag openblock %}', {}, '{%'),
     
    16121616            'static-statictag01': ('{% load static %}{% static "admin/base.css" %}', {}, urljoin(settings.STATIC_URL, 'admin/base.css')),
    16131617            'static-statictag02': ('{% load static %}{% static base_css %}', {'base_css': 'admin/base.css'}, urljoin(settings.STATIC_URL, 'admin/base.css')),
    16141618        }
     1619        # Until Django 1.5, the ssi tag takes an unquoted constant in
     1620        # argument, and there's no way to escape spaces. As a consequence
     1621        # it's impossible to include a file if its absolute path contains
     1622        # a space. If this happens, we can't run the following tests.
     1623        if ' ' in basedir:
     1624            del tests['old-ssi01'], tests['old-ssi02'], tests['old-ssi06'], tests['old-ssi07']
     1625        return tests
    16151626
     1627
    16161628class TemplateTagLoading(unittest.TestCase):
    16171629
    16181630    def setUp(self):
  • tests/regressiontests/templates/templates/ssi

     
     1This is for testing an ssi include with spaces in its name. {{ test }}
Back to Top