Commit graph

90 commits

Author SHA1 Message Date
Hanif Birgani
4753698765 fix(context): change context template in the template file and rename context dict keys with default values. 2023-10-09 22:28:11 +02:00
Hanif Birgani
ba436c0080 fix: raise command error if path or BASE_DIR not available 2023-10-09 22:28:11 +02:00
pre-commit-ci[bot]
4f4b81b7a0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-10-09 22:28:11 +02:00
Hanif Birgani
58c7d55256 fix(management):
- Add `path` argument for custom component path
- Add `js`, `css`, `template` arguments for custom component script, style and template files
- Add `force` argument to force rewrite the existing component
- Add `verbose` option to make the command more informative
- Add `dry-run` option to simulate the command without writing to disk
- related #249
2023-10-09 22:28:11 +02:00
Hanif Birgani
af107910a6 fix(management):
- use `textwrap.dedent` for better readability
- remove unused comments from generated python file
- related #249
2023-10-09 22:28:11 +02:00
Hanif Birgani
a45bfdc837 fix(management): change a line to pass flake8. related #249 2023-10-09 22:28:11 +02:00
pre-commit-ci[bot]
deb17c6c70 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-10-09 22:28:11 +02:00
Hanif Birgani
825b0cbbaa feat(management): [WIP] add startcomponent management command. related #249 2023-10-09 22:28:11 +02:00
pre-commit-ci[bot]
6a633c67a8 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-09-29 16:06:52 +02:00
Roman Imankulov
a919b648b3 Add support for - and / in component names in middleware
- Fix the COMPONENT_COMMENT_REGEX to find component names with special symbols.
- Fix the test to catch the error.

Follow-up of e0c29e5 and ref: #262
2023-09-29 16:06:52 +02:00
Emil Stenström
e0c29e55b7 Add support for - and / in component names in middleware. 2023-09-03 11:44:40 +02: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
Timothy
1bbd4a1f3c
Use valid script tag HTML to avoid console errors (#271) 2023-04-24 17:37:59 +02:00
vojtech
814f526658 ignore .pyc files in collectstatic 2023-04-22 01:27:35 +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
adriaan
fa41387a53
Introduce safer_staticfiles app as user-friendly security measure for #260 (#261)
* Introduce safer_staticfiles app to ignore .py,.html as security measure. Docs up-to-date

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-04-11 13:55:11 +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
Serafeim Papastefanos
f68390953a
Fix for #239 (#240)
* Fix for #239
* Improve patch
2023-03-20 17:06:00 +01: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
47af3151e2 Merge branch 'master' of https://github.com/EmilStenstrom/django-components 2023-02-09 22:15:51 +01:00
Emil Stenström
36237f0752 Make Media.css and Media.js optional. 2023-02-09 22:15:47 +01:00
pre-commit-ci[bot]
0996a14544 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-02-07 04:59:41 +00:00
Emil Stenström
9578ef16cd
Merge branch 'master' into master 2023-01-04 00:07:03 +01:00
Emil Stenström
b2a328d9ab Add *args and **kwargs to make typecheckers and linters happy. 2022-12-13 12:30:56 +01:00
Rafael P
dcbe0bccd1 Issue loading media when RENDER_DEPENDENCIES True 2022-07-31 20:18:41 -05:00
Emil Stenström
f5c3f64c86 Handle case with SETTINGS_MODULE not set. 2022-07-18 09:23:04 +02:00
Emil Stenström
681c540cb7 Can't use wahlrus operator in old pythons. 2022-07-18 09:21:10 +02:00
Emil Stenström
18ee5ad3b0 Autodetect components inside component subdirectories to make setup easier. 2022-07-18 09:13:03 +02:00
Emil Stenström
58c6e476f1 Automitically load component templates from directory where settings.py files is (old style), and from settings.py parent dir (new style). 2022-07-17 13:26:27 +02:00
Emil Stenström
29e6d1a4a0 Delay loading component until rendering, and clean up usage of component variable. 2022-07-14 12:47:06 +02:00
pre-commit-ci[bot]
16065367d5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-07-14 10:34:34 +02:00
AIT ALI EL HOSAYN
bfd55f9fbe Component name as variable
I have removed the exception raising when a variable without quotes is given, and keep the variable name until the render function where I'm resolving it if it's a String (which means it's a variable, not a component) then I'm moving the slot parts which relies on the component from __init__ to render after getting the component.
2022-07-14 10:34:34 +02:00
Emil Stenström
77e4cdc543 Remove deprecation warning in Django > 3.2. 2022-07-14 09:45:42 +02:00
David Guillot
f67cd37dea feat(templatetags): fix #143, ability to preload components 2022-04-29 00:06:06 +02:00
David Guillot
021339d4a7 refactor(templatetags): make _RENDERED comment a constant 2022-04-29 00:01:50 +02: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
Real-Gecko
c1d090d5c0
Added template loader for component templates automatic discovery (thanks @Real-Gecko) 2021-08-30 22:51:03 +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