# Path: handroll/exceptions.py
# class AbortError(Exception):
#     """Any fatal errors that would prevent handroll from proceeding should
#     signal with the ``AbortError`` exception."""
# 
# Path: handroll/i18n.py



import os
import jinja2
from jinja2 import meta
from handroll.exceptions import AbortError
from handroll.i18n import _
# Copyright (c) 2017, Matt Layman





class JinjaTemplateBuilder(object):

    def __init__(self, templates_path):
        self.templates_path = templates_path
        loader = jinja2.FileSystemLoader(templates_path)
        self._env = jinja2.Environment(
            loader=loader, trim_blocks=True, auto_reload=False)
        self._templates_modified_times = {}

    def build(self, template_path):
        """Build a Jinja template from the file path."""
        # Strip the templates path from the template path to get the relative
        # name that the ``FileSystemLoader`` wants.
        template_name = os.path.relpath(template_path, self.templates_path)
        try:
            template = self._env.get_template(template_name)
            template.last_modified = self._get_last_modified(template_name,
                                                             template_path)
            return template
        except jinja2.exceptions.TemplateSyntaxError as e:

# Path: handroll/exceptions.py
# class AbortError(Exception):
#     """Any fatal errors that would prevent handroll from proceeding should
#     signal with the ``AbortError`` exception."""
# 
# Path: handroll/i18n.py



# Path: handroll/template/j2.py
import os
import jinja2
from jinja2 import meta
from handroll.exceptions import AbortError
from handroll.i18n import _

# Copyright (c) 2017, Matt Layman





class JinjaTemplateBuilder(object):

    def __init__(self, templates_path):
        self.templates_path = templates_path
        loader = jinja2.FileSystemLoader(templates_path)
        self._env = jinja2.Environment(
            loader=loader, trim_blocks=True, auto_reload=False)
        self._templates_modified_times = {}

    def build(self, template_path):
        """Build a Jinja template from the file path."""
        # Strip the templates path from the template path to get the relative
        # name that the ``FileSystemLoader`` wants.
        template_name = os.path.relpath(template_path, self.templates_path)
        try:
            template = self._env.get_template(template_name)
            template.last_modified = self._get_last_modified(template_name,
                                                             template_path)
            return template
        except jinja2.exceptions.TemplateSyntaxError as e:

            raise AbortError(