Skip to content

Commit d67e13c

Browse files
authored
Allow using variable as identifier in static_alias template tag (#191)
1 parent ab22c8d commit d67e13c

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Changelog
33
=========
44

5+
Unreleased
6+
==========
7+
* fix: Allow using a variable as the identifier in static_alias template tag
8+
59
2.0.0rc1
610
========
711
* Django 4.0, 4.1, and 4.2 support added

djangocms_alias/templatetags/djangocms_alias_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class StaticAlias(Tag):
6969
"""
7070
name = 'static_alias'
7171
options = PlaceholderOptions(
72-
Argument('static_code', resolve=False),
72+
Argument('static_code', resolve=True),
7373
MultiValueArgument('extra_bits', required=False, resolve=False),
7474
blocks=[
7575
('endstatic_alias', 'nodelist'),

tests/test_templatetags.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,22 @@ def page_edit_url(lang):
340340

341341
self.assertIsNotNone(alias.get_content("en", show_draft_content=True))
342342
self.assertIsNotNone(alias.get_content("de", show_draft_content=True))
343+
344+
def test_alias_rendered_when_identifier_is_variable(self):
345+
alias_template = """{% load djangocms_alias_tags %}{% static_alias foo_variable %}""" # noqa: E501
346+
347+
alias = self._create_alias(static_code="some_unique_id")
348+
add_plugin(
349+
alias.get_placeholder(self.language),
350+
'TextPlugin',
351+
language=self.language,
352+
body='Content Alias 1234',
353+
)
354+
355+
output = self.render_template_obj(
356+
alias_template,
357+
{'foo_variable': "some_unique_id"},
358+
self.get_request('/'),
359+
)
360+
361+
self.assertEqual(output, "Content Alias 1234")

0 commit comments

Comments
 (0)