carltongibson / django-template-partials

Reusable named inline partials for the Django Template Language.
MIT License
387 stars 15 forks source link

Add autoconfiguration of partials loader. #11

Closed vsajip closed 9 months ago

vsajip commented 1 year ago

Should fix #10. I didn't create a separate wrap_loaders() function as I wasn't sure where it would be called / where it should go if called from outside this package. Would appreciate your comments!

vsajip commented 1 year ago

Hmmm. GitHub Actions failing, but tests run fine locally ...

$ just test
django-admin test --settings=tests.settings --pythonpath=. 
Found 5 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.....
----------------------------------------------------------------------
Ran 5 tests in 0.008s

OK
Destroying test database for alias 'default'...

$ just coverage
coverage erase
coverage run -m django test --settings=tests.settings --pythonpath=.
Found 5 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.....
----------------------------------------------------------------------
Ran 5 tests in 0.012s

OK
Destroying test database for alias 'default'...
coverage report
Name                                             Stmts   Miss  Cover
--------------------------------------------------------------------
src/template_partials/__init__.py                    1      0   100%
src/template_partials/apps.py                       19      0   100%
src/template_partials/loader.py                     30      7    77%
src/template_partials/templatetags/__init__.py       0      0   100%
src/template_partials/templatetags/partials.py      53      4    92%
tests/__init__.py                                    0      0   100%
tests/settings.py                                    5      0   100%
tests/templates/debug.html                           8      0   100%
tests/templates/example.html                        12      0   100%
tests/tests.py                                      35      0   100%
--------------------------------------------------------------------
TOTAL                                              163     11    93%
vsajip commented 1 year ago

Did you get a chance to take a look, @carltongibson?

carltongibson commented 1 year ago

Hey @vsajip, no not yet. I have a few personal issues going on right now that have kept me away. I will get to it though! Thanks for the input.

vsajip commented 1 year ago

Are you up for making a few adjustments? ... Let me know if that makes sense.

Sure. I'll look at this when I can!

carltongibson commented 1 year ago

Great. Thanks! 🎁

vsajip commented 12 months ago

and let it take a backend alias

What exactly do you mean here? Databases have aliases, sure, but template backends are a list of backends such as Django, Jinja2 etc. denoted by the backend engine class name - what does "alias" refer to in this context? Do you mean the value of the BACKEND key in a dictionary in TEMPLATES?

carltongibson commented 12 months ago

I mean the NAME key, which you'd use in particular if configuring multiple Django backends.

vsajip commented 12 months ago

I mean the NAME key

Oh, I see. That was under my radar as I've never actually used it - never had to configure several instances of the same backend with different options.

Also,

I would leave and adjust the existing example, so people have that if they need it.

Do you mean the usage example? I'm assuming the example of configuration of the loaders isn't needed, as wrap_loaders does it and it's not needed in common usage.

carltongibson commented 12 months ago

There are lots of folks defining loaders by hand, so they'll find having it stated explicitly helpful.

vsajip commented 12 months ago

So just leave as is, but move to where "wrap_loaders" is mentioned?

carltongibson commented 12 months ago

Yeah...

Option 1 is just add to installed apps.

Option 2 is use the simple AppConfig but then configure loaders yourself (either with wrap loaders or by hand)

vsajip commented 12 months ago

I've pushed changes addressing your comments, but for some reason GitHub hasn't picked them up.

vsajip commented 12 months ago

I've logged an issue with GitHub, let's see what happens.

vsajip commented 12 months ago

The GH issue appears to have resolved itself. My last commit is now showing, so you should be able to review my changes.

carltongibson commented 12 months ago

Thanks @vsajip 🙏

Just so you know, life is pretty full-on just now, so I may be a week or so to review this.

Awesome effort! 🎁

vsajip commented 12 months ago

Oh hey, no worries! I'm using this library, liking it, and I like to give back. Take your time :smile:

carltongibson commented 10 months ago

@vsajip Thanks for your patience here. Just so you know, I'll looking at this now, and am hoping to do a release for a new version in the next week or so. 🎁