# Path: django_make_app/renderers.py
# class TemplateRenderer(object):
#     def __init__(self, templates_directory, template_name, item):
#         """
#         :type templates_directory: os.path
#         :type template_name: unicode
#         :type item: dict
#         """
#         self._templates_directory = templates_directory
#         self.template_name = template_name
#         self.item = item
# 
#     def _render_from_template(self, template_name, **kwargs):
#         loader = FileSystemLoader(self._templates_directory)
#         env = Environment(loader=loader)
#         template = env.get_template(template_name)
# 
#         render = template.render(**kwargs)
# 
#         render = render.replace("[[", "{{")
#         render = render.replace("]]", "}}")
# 
#         render = render.replace("[%", "{%")
#         render = render.replace("%]", "%}")
# 
#         return render
# 
#     def render(self, context):
#         """
# 
#         :type context: dict
#         """
#         if "_model" in self.item:
#             context.update({
#                 "current_model": self.item.get('_model')
#             })
# 
#         return self._render_from_template(self.template_name, **context)


import os
import tempfile
from unittest import TestCase
from django_make_app.renderers import TemplateRenderer
# -*- encoding: utf-8 -*-
# ! python2

from __future__ import (absolute_import, division, print_function, unicode_literals)




class RenderersTestCase(TestCase):
    def test_template_renderer(self):
        try:
            with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp:
                temp.write("{{ hello }}")

            templates_directory = os.path.dirname(temp.name)
            template_name = os.path.basename(temp.name)

# Path: django_make_app/renderers.py
# class TemplateRenderer(object):
#     def __init__(self, templates_directory, template_name, item):
#         """
#         :type templates_directory: os.path
#         :type template_name: unicode
#         :type item: dict
#         """
#         self._templates_directory = templates_directory
#         self.template_name = template_name
#         self.item = item
# 
#     def _render_from_template(self, template_name, **kwargs):
#         loader = FileSystemLoader(self._templates_directory)
#         env = Environment(loader=loader)
#         template = env.get_template(template_name)
# 
#         render = template.render(**kwargs)
# 
#         render = render.replace("[[", "{{")
#         render = render.replace("]]", "}}")
# 
#         render = render.replace("[%", "{%")
#         render = render.replace("%]", "%}")
# 
#         return render
# 
#     def render(self, context):
#         """
# 
#         :type context: dict
#         """
#         if "_model" in self.item:
#             context.update({
#                 "current_model": self.item.get('_model')
#             })
# 
#         return self._render_from_template(self.template_name, **context)


# Path: tests/test_renderers.py
import os
import tempfile
from unittest import TestCase
from django_make_app.renderers import TemplateRenderer

# -*- encoding: utf-8 -*-
# ! python2

from __future__ import (absolute_import, division, print_function, unicode_literals)




class RenderersTestCase(TestCase):
    def test_template_renderer(self):
        try:
            with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp:
                temp.write("{{ hello }}")

            templates_directory = os.path.dirname(temp.name)
            template_name = os.path.basename(temp.name)

            renderer = TemplateRenderer(templates_directory=templates_directory, template_name=template_name, item={})