Skip to content
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

modularized the view class a bit #309

Merged
merged 1 commit into from
Sep 9, 2018
Merged
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
12 changes: 8 additions & 4 deletions masonite/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, container):

self.template = None
self.environments = []
self.extension = '.html'
self._filters = {}

def render(self, template, dictionary={}):
Expand Down Expand Up @@ -71,10 +72,13 @@ def render(self, template, dictionary={}):
if self.composers:
self._update_from_composers()

self.rendered_template = self.env.get_template(self.filename).render(
self.dictionary)
self.rendered_template = self._render()

return self

def _render(self):
return self.env.get_template(self.filename).render(
self.dictionary)

def _update_from_composers(self):
"""Adds data into the view from specified composers.
Expand Down Expand Up @@ -223,12 +227,12 @@ def __load_environment(self, template):
"""

self.template = template
self.filename = template + '.html'
self.filename = template + self.extension

if template.startswith('/'):
# Filter blanks strings from the split
location = list(filter(None, template.split('/')))
self.filename = location[-1] + '.html'
self.filename = location[-1] + self.extension

loader = PackageLoader(location[0], '/'.join(location[1:-1]))

Expand Down