Skip to content

Commit

Permalink
Convert render_charts to simple tag
Browse files Browse the repository at this point in the history
This allows the tag to be called easily from jinja2
  • Loading branch information
RealOrangeOne authored and saevarom committed Aug 6, 2024
1 parent f45f937 commit 05bf49e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions wagtailcharts/templatetags/wagtailcharts_tags.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django import template
from django.template.loader import render_to_string

register = template.Library()

@register.inclusion_tag('wagtailcharts/tags/render_charts.html')
def render_charts():
pass
@register.simple_tag(takes_context=True)
def render_charts(context):
return render_to_string('wagtailcharts/tags/render_charts.html', context=context)

@register.filter()
def addspace(val):
return val.replace("_", " ")
return val.replace("_", " ")

0 comments on commit 05bf49e

Please sign in to comment.