Skip to content

Commit

Permalink
fix: Pass request object to render_string (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousLearner authored Apr 2, 2024
1 parent 34a6ff9 commit 6a4db66
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion pattern_library/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <ben.dickinson@torchbox.com>",
Expand Down

0 comments on commit 6a4db66

Please sign in to comment.