PHACDataHub / django-phac_aspc-helpers

Provides a series of helpers to provide a consistent experience accross PHAC-ASPC's Django based projects.
MIT License
0 stars 0 forks source link

DTL templatetag for rendering Jinja content in to a DTL template #43

Closed Stephen-ONeil closed 1 year ago

Stephen-ONeil commented 1 year ago

Pretty trivial. ~A utility function for rendering a DTL template in Jinja would look almost identical (I believe the only difference is that their render function expects context to be passed as keywords instead of a dict), but I'm thinking we don't want to provide that. This is to support transitioning from DTL to Jinja.~ Ok, I'll do both directions.

TODO:

github-actions[bot] commented 1 year ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
phac_aspc/django
   excel.py1482881%17–18, 49, 71, 81, 85, 119–121, 125–129, 132–133, 162, 170, 187–188, 214, 217, 219, 221, 224, 230, 236, 255–256, 263–264
   fields.py791680%46, 67–80, 102–105, 120–125, 128–132
phac_aspc/django/admin/decorators
   admin_decorators.py18289%37–38
phac_aspc/django/helpers/auth
   backend.py28280%2–36
   views.py442739%21, 26–29, 34–42, 47–99
phac_aspc/django/helpers/locale
   code.py8362%10, 13–14
phac_aspc/django/helpers/templatetags
   phac_aspc_auth.py7186%13
   phac_aspc_jinja_include.py12192%31
   phac_aspc_localization.py11464%11, 26–29
phac_aspc/django/helpers/views
   wet.py10640%12–19
phac_aspc/django/localization
   hooks.py660%2–16
phac_aspc/django/localization/decorators
   __init__.py220%4–6
   localization_decorators.py11110%4–46
phac_aspc/django/settings
   security.py251252%41–69
   utils.py54296%103, 154
TOTAL57414974% 

Tests Skipped Failures Errors Time
20 0 :zzz: 0 :x: 0 :fire: 2.004s :stopwatch:
AlexCLeduc commented 1 year ago

This is cool! Can we also do it the other way around? I think it'll be more common to use 3rd party DTL inclusions in our 1st party jinja templates

Stephen-ONeil commented 1 year ago

Alright, I'll write the reverse version too.

Getting a pretty obtuse error in python 3.8 and 3.9. Do we need to support those still?

AlexCLeduc commented 1 year ago

I think we can drop support, no projects are using 3.8/3.9. We should be using 3.11 everywhere, though some dev environments might be using 3.10

github-actions[bot] commented 1 year ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
phac_aspc/django
   excel.py1482881%17–18, 49, 71, 81, 85, 119–121, 125–129, 132–133, 162, 170, 187–188, 214, 217, 219, 221, 224, 230, 236, 255–256, 263–264
   fields.py791680%46, 67–80, 102–105, 120–125, 128–132
phac_aspc/django/admin/decorators
   admin_decorators.py18289%37–38
phac_aspc/django/helpers
   jinja_dtl_interop_utils.py7186%21
phac_aspc/django/helpers/auth
   backend.py28280%2–36
   views.py442739%21, 26–29, 34–42, 47–99
phac_aspc/django/helpers/locale
   code.py8362%10, 13–14
phac_aspc/django/helpers/templatetags
   phac_aspc_auth.py7186%13
   phac_aspc_localization.py11464%11, 26–29
phac_aspc/django/helpers/views
   wet.py10640%12–19
phac_aspc/django/localization
   hooks.py660%2–16
phac_aspc/django/localization/decorators
   __init__.py220%4–6
   localization_decorators.py11110%4–46
phac_aspc/django/settings
   security.py251252%41–69
   utils.py54296%103, 154
TOTAL58814975% 

Tests Skipped Failures Errors Time
22 0 :zzz: 0 :x: 0 :fire: 2.067s :stopwatch:
AlexCLeduc commented 1 year ago

If I followed the imports correctly, it looks like this won't break DTL projects that don't have jinja installed, correct?