From ed629578e00203982a934d8c308517dcab40404e Mon Sep 17 00:00:00 2001 From: Sanyam Khurana Date: Wed, 3 Apr 2024 02:35:18 +0530 Subject: [PATCH] fix: Pass request object to render_string --- CHANGELOG.md | 6 ++++++ pattern_library/views.py | 5 ++++- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2146c..c839911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.2.1dev2](https://github.com/lincolnloop/django-pattern-library/releases/tag/v1.2.1dev2) - 2024-04-02 + +### Fixed + +- Pass request object to HTML rendered code view ([#3](https://github.com/lincolnloop/django-pattern-library/pull/3)) + ## [1.2.1dev1](https://github.com/lincolnloop/django-pattern-library/releases/tag/v1.2.1dev1) - 2024-04-02 ### Added diff --git a/pattern_library/views.py b/pattern_library/views.py index 33bc976..05f257b 100644 --- a/pattern_library/views.py +++ b/pattern_library/views.py @@ -78,7 +78,10 @@ def get(self, request, pattern_template_name=None): template_context = get_pattern_context(pattern_template_name) try: soup = BeautifulSoup( - render_to_string(pattern_template_name, template_context), "html.parser" + render_to_string( + pattern_template_name, template_context, request=request + ), + "html.parser", ) formatter = HTMLFormatter(indent=4) context["pattern_html_source"] = escape(soup.prettify(formatter=formatter)) diff --git a/pyproject.toml b/pyproject.toml index 95d378f..6b9fb82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-pattern-library" -version = "1.2.1dev1" +version = "1.2.1dev2" description = "A module for Django that allows to build pattern libraries for your projects." authors = [ "Ben Dickinson ",