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
28569a66
Commit
28569a66
authored
Dec 23, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved load_template to end of Render.__init__() argument list.
parent
b0e78f9a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
pystache/renderer.py
+11
-11
pystache/view.py
+2
-1
No files found.
pystache/renderer.py
View file @
28569a66
...
@@ -22,18 +22,13 @@ except ImportError:
...
@@ -22,18 +22,13 @@ except ImportError:
class
Renderer
(
object
):
class
Renderer
(
object
):
def
__init__
(
self
,
load_template
=
None
,
output_encoding
=
None
,
escape
=
None
,
def
__init__
(
self
,
output_encoding
=
None
,
escape
=
None
,
default_encoding
=
None
,
decode_errors
=
'strict'
):
default_encoding
=
None
,
decode_errors
=
'strict'
,
load_template
=
None
):
"""
"""
Construct an instance.
Construct an instance.
Arguments:
Arguments:
load_template: a function for loading templates by name, for
example when loading partials. The function should accept a
single template_name parameter and return a template as a string.
Defaults to the default Loader's get() method.
output_encoding: the encoding to use when rendering to a string.
output_encoding: the encoding to use when rendering to a string.
The argument should be the name of an encoding as a string, for
The argument should be the name of an encoding as a string, for
example "utf-8". See the render() method's documentation for more
example "utf-8". See the render() method's documentation for more
...
@@ -61,17 +56,22 @@ class Renderer(object):
...
@@ -61,17 +56,22 @@ class Renderer(object):
strings of type `str` encountered during the rendering process.
strings of type `str` encountered during the rendering process.
Defaults to "strict".
Defaults to "strict".
"""
load_template: a function for loading templates by name, for
if
load_template
is
None
:
example when loading partials. The function should accept a
loader
=
Loader
()
single template_name parameter and return a template as a string.
load_template
=
loader
.
get
Defaults to the default Loader's get() method.
"""
if
default_encoding
is
None
:
if
default_encoding
is
None
:
default_encoding
=
sys
.
getdefaultencoding
()
default_encoding
=
sys
.
getdefaultencoding
()
if
escape
is
None
:
if
escape
is
None
:
escape
=
markupsafe
.
escape
if
markupsafe
else
cgi
.
escape
escape
=
markupsafe
.
escape
if
markupsafe
else
cgi
.
escape
if
load_template
is
None
:
loader
=
Loader
()
load_template
=
loader
.
get
literal
=
markupsafe
.
Markup
if
markupsafe
else
unicode
literal
=
markupsafe
.
Markup
if
markupsafe
else
unicode
self
.
_literal
=
literal
self
.
_literal
=
literal
...
...
pystache/view.py
View file @
28569a66
...
@@ -99,7 +99,8 @@ class View(object):
...
@@ -99,7 +99,8 @@ class View(object):
"""
"""
template
=
self
.
get_template
()
template
=
self
.
get_template
()
renderer
=
Renderer
(
self
.
load_template
,
output_encoding
=
encoding
,
escape
=
escape
)
renderer
=
Renderer
(
output_encoding
=
encoding
,
escape
=
escape
,
load_template
=
self
.
load_template
)
return
renderer
.
render
(
template
,
self
.
context
)
return
renderer
.
render
(
template
,
self
.
context
)
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