Skip to content

Commit

Permalink
Pass Context instances to Template.render. See Wirecloud#289
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz authored and Alejandro Rodriguez committed Jul 24, 2017
1 parent 657fca7 commit 8e24690
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/wirecloud/platform/widget/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from django.core.cache import cache
from django.conf import settings
from django.db.models import Q
from django.template import Template
from django.template import Context, Template
from lxml import etree

from wirecloud.catalogue.models import CatalogueResource
Expand Down Expand Up @@ -126,7 +126,7 @@ def get_widget_platform_style(theme):

code += '{% endcompress %}'

result = Template(code).render({})
result = Template(code).render(Context())
doc = etree.parse(BytesIO(('<files>' + result + '</files>').encode('utf-8')), etree.XMLParser())

files = [link.get('href') for link in doc.getroot()]
Expand All @@ -150,7 +150,7 @@ def get_widget_api_files(request):
<script type="text/javascript" src="{% static "js/WirecloudAPI/WirecloudAPICommon.js" %}"></script>
{% endcompress %}'''

result = Template(code).render({})
result = Template(code).render(Context())
doc = etree.parse(BytesIO(('<files>' + result + '</files>').encode('utf-8')), etree.XMLParser())

files = [script.get('src') for script in doc.getroot()]
Expand Down
4 changes: 2 additions & 2 deletions src/wirecloud/platform/wiring/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from io import BytesIO

from django.conf import settings
from django.template import loader, Template
from django.template import Context, loader, Template
from lxml import etree

from wirecloud.commons.utils.http import get_absolute_static_url, get_current_domain
Expand Down Expand Up @@ -83,7 +83,7 @@ def get_operator_api_files(request):
<script type="text/javascript" src="{% static "js/WirecloudAPI/WirecloudAPICommon.js" %}"></script>
{% endcompress %}'''

result = Template(code).render({})
result = Template(code).render(Context())
doc = etree.parse(BytesIO(('<files>' + result + '</files>').encode('utf-8')), etree.XMLParser())

files = [script.get('src') for script in doc.getroot()]
Expand Down

0 comments on commit 8e24690

Please sign in to comment.