Commit graph

54 commits

Author SHA1 Message Date
Emil Stenström
48fe8171b4 Reformat lines that became too long. And enforce 119 line length. 2024-02-21 22:38:06 +01:00
Emil Stenström
ef6a082238 Remove component tag in favour of component_block. 2024-02-21 22:38:06 +01:00
pre-commit-ci[bot]
eac0cb6f4b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-01-29 20:46:50 +00:00
Dylan Castillo
dc9f1b46b2
Fix issue #368 and add tests (#369) 2024-01-27 23:10:03 +01:00
Dylan Castillo
91b4accfeb
Render components as views (#366) (thanks @dylanjcastillo) 2024-01-24 22:36:57 +01:00
Dylan Castillo
70a2a01400 Implement single file components 2024-01-14 22:36:55 +01:00
VojtechPetru
26bd72a9e2
Invalid slot more helpful message (#283)
* more helpful message when filling invalid slot name

* Update tests/test_templatetags.py

Co-authored-by: Emil Stenström <emil@emilstenstrom.se>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add missing import; set -> typing.Set

* fix after rebase

* set -> typing.Set

* let -> typing.List

* Reduce duplicated effort; extend helpfulness; add extra comments

code qa

---------

Co-authored-by: Emil Stenström <emil@emilstenstrom.se>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: lemontheme <lemontheme@gmail.com>
2023-05-22 14:54:18 +02:00
adriaan
2d86f042da
Implement #231 – default slot filling (#269)
* Add 'default' slot option + implicit fills; tests; docs
* Differentiate between standard fillnodes and implicitfillnodes on type lvl
* Reworking slot-fill rendering logic. Simplifying component interfact. Add new get_string_template method
* First working implementation of chainmap instead of stacks for slot resolution
* Stop passing FillNode to Component initalizer -> better decoupling
* Treat fill name and alias and component name as filterexpression, dropping namedvariable
* Name arg of if_filled tags and slots must be string literal
2023-05-18 14:58:46 +02:00
adriaan
6f49339c91
fix/263 performance regression (#264)
* Replace deep copies in Component.render
* Add 2nd example component to sampleproject
2023-04-13 14:20:43 +02:00
lemontheme
bb181f47b0 Remove dangling comment 2023-04-06 16:08:17 +02:00
lemontheme
a47b007f67 Fix #250 (3.6 failing) by removing postponed eval of type hints. 2023-04-06 15:52:45 +02:00
lemontheme
898d148382 Add required kwd to slot tag and add test
Move required slot check to SlotNode.render(); clean up needed

Remove unused code; drop caching

Update docs

Incorporate PR feedback
2023-03-14 23:40:21 +01:00
lemontheme
a8dfcce24e Introduce {% fill %} replacing 'fill' func of 'slot' tag
Partial implementation fill-tags plus update tests

Implement {% fill %} tags. Next: update tests.

Bring back support for {%slot%} blocks for bckwrd-compat and implement ambig. resolution policy

Update tests to use fill blocks. Add extra checks that raise errors

Add new tests for fill-slot nesting

Update README. Editing still required

remove unused var ctxt after flake8 complaint

fix flake8 warning about slotless f-string

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Add new slot aliases in fill context. Clean up rendering logic in Component. Update docs.

fix flake8, isort, black errors

Refactor duplicated name validation

Add if_filled tag + elif_filled...else_filled...endif_filled for cond. slots

Fix mistake in do_if_filled() docstring

Upload templates for tests! D'oh

Incorporate PR feedback

Drop Literal type hint; Use isort off-on instead of skip in tests

Treat all fill,slot,if_filled,component names as variables

Reset sampleproject components

Add test for variable filled name

Update examples in docs
2023-03-14 23:40:21 +01:00
Emil Stenström
36237f0752 Make Media.css and Media.js optional. 2023-02-09 22:15:47 +01:00
Emil Stenström
b2a328d9ab Add *args and **kwargs to make typecheckers and linters happy. 2022-12-13 12:30:56 +01:00
Hanif Birgani
b5414d4920 Convert a single line long string to multi-line to pass flake8 2021-09-10 15:46:25 +04:30
pre-commit-ci[bot]
0648ad9a93 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-09-10 11:12:26 +00:00
Emil Stenström
a2f0e2246b Require get_context_data set to accept parameters. 2021-09-10 12:29:47 +02:00
Real-Gecko
5fcabaa5ba Renamed get_context to get_context_data 2021-09-10 11:27:55 +02:00
Emil Stenström
5b9188cc9c Refactored Component class
# Conflicts:
#	README.md
#	pyproject.toml
2021-09-10 11:27:28 +02:00
rbeard0330
e3c9ac76ce
Fix infinite recursion bug (fixes #68) (#74)
* Add regression test for recursion bug, #68

* Only allow slots to access slot nodelists provided to their immediate parent component to prevent infinite recursions.

* Fix import ordering bug in test

* Add slot.super to docs

Remove unused imports

* Bump version

Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-07-06 11:56:49 -04:00
Emil Stenström
a5bd0cf2e3
Rework slot management to avoid nodelist copying (fixes #64)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-05-30 18:46:11 +02:00
rbeard0330
070b754d24 Improve slot handling to allow nested components, conditional slots, and slot.super (Fixes #33, #34, #37)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-05-26 00:59:46 +02:00
Emil Stenström
57a5aa0f4b
Only render dependencies that are used of a specific page (#52)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-03-24 22:47:48 +01:00
Emil Stenström
b8f14404ac Allow simpler definition of Media class. 2021-03-10 22:36:42 +01:00
Emil Stenström
c67fd29bdd Move in_slot_node helper into Component class. 2021-03-10 17:47:51 +01:00
Emil Stenström
b9446c2818
Add support for calling register as a decorator (#38) 2021-02-27 16:38:16 +01:00
Dan Jacob
10a117ee88 Class decorator and test 2021-02-27 16:49:06 +02:00
Emil Stenström
07986c5216
Caching templates to allow for dynamic template generation
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-02-15 21:07:14 +01:00
Emil Stenström
8f2440a757 Remove six. 2021-02-12 22:38:58 +01:00
Emil Stenström
2c95b0930f Remove support for Python < 3.6 and Django < 2.2. 2021-02-12 21:10:33 +01:00
rbeard0330
87f9994c81
Performance (+50%): Compile ComponentNode at creation, not render (#22)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-02-06 10:09:57 +01:00
rbeard0330
1ea86fc50d
Create cloned template for rendering so test instrumentation works.
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-01-31 23:18:04 +01:00
rbeard0330
2633c3f08f
Pass context into component tags by default, and let components disable with "only" (#20)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2021-01-25 12:31:54 +01:00
rbeard0330
979dc82eda
Fix bug where template with multiple component_block tags could raise KeyError (#19)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2020-12-30 08:01:57 +01:00
rbeard0330
93b8a7404a
Rework of context handling (#18)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2020-12-28 10:40:35 +01:00
rbeard0330
be0a75e2a3
Missing context variables and kwargs in component_block (#17)
* Fix issue with missing variables by binding template to context in Component.render method.
* Pass extra_context to Component.render()

Co-authored-by: rbeard0330 <@dul2k3BKW6m>
2020-12-14 18:25:36 +01:00
Emil Stenström
34098c375a Sort imports to isort is happy. 2020-11-02 15:08:26 +01:00
Bradley Stuart Kirton
2c644d4c06 Add pytest-cov
Apply black formatting
Add component_css_dependencies_tag and component_js_dependencies_tag tags
Add convenience methods render_css_dependencies and render_js_dependencies to component class
Create additional test cases
Add license to setup.py
Add pytest.ini config file
2020-07-10 13:07:51 +02:00
Emil Stenström
5f63a6a6bd Add test for component with undefined template method. 2020-06-07 17:07:24 +02:00
Emil Stenström
b2f61b61ad Fix flake8. 2020-06-07 08:45:54 +02:00
Emil Stenström
9811a88904 Add backwards compatible getfullargspec and TokenType. 2020-06-06 09:29:51 +02:00
Emil Stenström
d1405dda13 Add slots to components that can be filled when using component. 2020-06-06 09:11:27 +02:00
Emil Stenström
40ebd6b936 Install isort and fix all imports. 2019-11-24 11:09:14 +01:00
Emil Stenström
cbe2bcc9c9 Use six to allow metaclass usage in both Python 2 and 3. 2019-11-24 10:57:55 +01:00
Emil Stenström
096057b33d Use built-in django form assets instead of custom logic. 2019-11-24 10:31:23 +01:00
Emil Stenström
ebb180c540 Use list instead of tuple to avoid errors with missing comma. 2019-11-23 19:26:16 +01:00
Emil Stenström
33b1930ed5 Dependencies are the same for all instances, so convert to classmethod. 2015-06-14 14:28:43 +02:00
Emil Stenström
6492081b64 Add render() and render_dependencies() to Compoent. 2015-06-12 22:15:09 +02:00
Emil Stenström
31261ece08 Add a basic Component class. 2015-06-11 21:14:21 +02:00