Skip to content

added ability to provide a path to a template file #205

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pystache/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import sys
import os

from pystache import defaults
from pystache.common import TemplateNotFoundError, MissingTags, is_string
Expand Down Expand Up @@ -450,6 +451,8 @@ def render(self, template, *context, **kwargs):
all items in the *context list.

"""
if is_string(template) and os.path.isfile(template) and os.access(template, os.R_OK):
return self.render_path(self, template, *context, **kwargs)
if is_string(template):
return self._render_string(template, *context, **kwargs)
if isinstance(template, ParsedTemplate):
Expand Down