Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jinja2 Tag Support #268

Merged
merged 2 commits into from
Nov 30, 2019
Merged

Conversation

bmoe872
Copy link
Contributor

@bmoe872 bmoe872 commented Oct 15, 2019

What this does

Addresses: #265
By adding in some Jinja2 Tag Support!

I tried to keep this as consistent with how I've seen it done elsewhere, for instance looking at how wagtail handles Jinja2 tag support for their project.

There is a bit of setup, and I have yet to write tests.

Setup

To use these tags instead of the template tags, first you'll need to follow Jinja2 setup guides for Django templating, and wagtail templating. Namely my settings.py file looks like this in the end with all the important bits:

...
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.jinja2.Jinja2',
        'APP_DIRS': True,
        'DIRS': [
            os.path.join(DJANGO_ROOT, 'jinja2'),
        ],
        'OPTIONS': {
            'environment': '<YourProjectNameHere>.jinja2.environment',
            'extensions': [
                'wagtail.core.jinja2tags.core',
                'wagtail.admin.jinja2tags.userbar',
                'wagtail.images.jinja2tags.images',
                'longclaw.core.jinja2tags.core',
                'longclaw.basket.jinja2tags.basket',
                'longclaw.checkout.jinja2tags.checkout',
            ]
        },
    },
    # Django Template Settings
    # If you have default template tag support
    ...
]

I've got this working on a personal project, but have not run it through the longclaw test suite yet.

What still needs to be done

  • Tests should probably be written for some of this, even though it extends from the templatetags already written
  • Testing on the longclaw test suite

@codecov
Copy link

codecov bot commented Oct 15, 2019

Codecov Report

Merging #268 into master will decrease coverage by 2.58%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
- Coverage   86.74%   84.16%   -2.59%     
==========================================
  Files          61       64       +3     
  Lines        1366     1408      +42     
  Branches       62       62              
==========================================
  Hits         1185     1185              
- Misses        150      192      +42     
  Partials       31       31
Impacted Files Coverage Δ
longclaw/basket/jinja2tags.py 0% <0%> (ø)
longclaw/checkout/jinja2tags.py 0% <0%> (ø)
longclaw/core/jinja2tags.py 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0cac5ba...d378b3a. Read the comment docs.

@JamesRamm JamesRamm merged commit 1dfb817 into longclawshop:master Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants