Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
ccfa6075
Commit
ccfa6075
authored
Dec 17, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the Template class's view attribute.
parent
76dcc8ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
pystache/template.py
+17
-11
pystache/view.py
+1
-1
No files found.
pystache/template.py
View file @
ccfa6075
...
@@ -62,9 +62,16 @@ class Template(object):
...
@@ -62,9 +62,16 @@ class Template(object):
modifiers
=
Modifiers
()
modifiers
=
Modifiers
()
def
__init__
(
self
,
template
=
None
,
context
=
None
,
**
kwargs
):
def
__init__
(
self
,
template
=
None
,
context
=
None
,
load_template
=
None
,
**
kwargs
):
"""
"""
The context argument can be a dictionary, View, or Context instance.
Arguments:
context: a dictionary, View, or Context instance.
load_template: a function that accepts a single template_name
parameter and returns a template as a string. Defaults to the
default Loader's load_template() method.
"""
"""
from
.view
import
View
from
.view
import
View
...
@@ -77,6 +84,7 @@ class Template(object):
...
@@ -77,6 +84,7 @@ class Template(object):
if
isinstance
(
context
,
View
):
if
isinstance
(
context
,
View
):
view
=
context
view
=
context
context
=
view
.
context
.
copy
()
context
=
view
.
context
.
copy
()
load_template
=
view
.
load_template
elif
isinstance
(
context
,
Context
):
elif
isinstance
(
context
,
Context
):
context
=
context
.
copy
()
context
=
context
.
copy
()
else
:
else
:
...
@@ -86,13 +94,13 @@ class Template(object):
...
@@ -86,13 +94,13 @@ class Template(object):
if
kwargs
:
if
kwargs
:
context
.
push
(
kwargs
)
context
.
push
(
kwargs
)
if
view
is
None
:
if
load_template
is
None
:
view
=
View
()
loader
=
Loader
()
load_template
=
loader
.
load_template
self
.
context
=
context
self
.
context
=
context
self
.
load_template
=
load_template
self
.
template
=
template
self
.
template
=
template
# The view attribute is used only for its load_template() method.
self
.
view
=
view
self
.
_compile_regexps
()
self
.
_compile_regexps
()
...
@@ -171,8 +179,7 @@ class Template(object):
...
@@ -171,8 +179,7 @@ class Template(object):
def
_render_dictionary
(
self
,
template
,
context
):
def
_render_dictionary
(
self
,
template
,
context
):
self
.
context
.
push
(
context
)
self
.
context
.
push
(
context
)
template
=
Template
(
template
,
self
.
context
)
template
=
Template
(
template
,
self
.
context
,
self
.
load_template
)
template
.
view
=
self
.
view
out
=
template
.
render
()
out
=
template
.
render
()
self
.
context
.
pop
()
self
.
context
.
pop
()
...
@@ -210,9 +217,8 @@ class Template(object):
...
@@ -210,9 +217,8 @@ class Template(object):
@modifiers.set
(
'>'
)
@modifiers.set
(
'>'
)
def
_render_partial
(
self
,
template_name
):
def
_render_partial
(
self
,
template_name
):
markup
=
self
.
view
.
load_template
(
template_name
)
markup
=
self
.
load_template
(
template_name
)
template
=
Template
(
markup
,
self
.
context
)
template
=
Template
(
markup
,
self
.
context
,
self
.
load_template
)
template
.
view
=
self
.
view
return
template
.
render
()
return
template
.
render
()
@modifiers.set
(
'='
)
@modifiers.set
(
'='
)
...
...
pystache/view.py
View file @
ccfa6075
...
@@ -93,7 +93,7 @@ class View(object):
...
@@ -93,7 +93,7 @@ class View(object):
Return the view rendered using the current context.
Return the view rendered using the current context.
"""
"""
template
=
Template
(
self
.
get_template
(),
self
)
template
=
Template
(
self
.
get_template
(),
self
.
context
,
self
.
load_template
)
return
template
.
render
(
encoding
=
encoding
)
return
template
.
render
(
encoding
=
encoding
)
def
get
(
self
,
key
,
default
=
None
):
def
get
(
self
,
key
,
default
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment