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
c2fcba50
Commit
c2fcba50
authored
Dec 18, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed inner to section_contents.
parent
fd3d97fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
pystache/template.py
+8
-8
No files found.
pystache/template.py
View file @
c2fcba50
...
@@ -138,41 +138,41 @@ class Template(object):
...
@@ -138,41 +138,41 @@ class Template(object):
if
match
is
None
:
if
match
is
None
:
break
break
section
,
section_key
,
inner
=
match
.
group
(
0
,
1
,
2
)
section
,
section_key
,
section_contents
=
match
.
group
(
0
,
1
,
2
)
section_key
=
section_key
.
strip
()
section_key
=
section_key
.
strip
()
section_value
=
self
.
context
.
get
(
section_key
,
None
)
section_value
=
self
.
context
.
get
(
section_key
,
None
)
replacer
=
''
replacer
=
''
# Callable
# Callable
if
section_value
and
check_callable
(
section_value
):
if
section_value
and
check_callable
(
section_value
):
replacer
=
section_value
(
inner
)
replacer
=
section_value
(
section_contents
)
# Dictionary
# Dictionary
elif
section_value
and
hasattr
(
section_value
,
'keys'
)
and
hasattr
(
section_value
,
'__getitem__'
):
elif
section_value
and
hasattr
(
section_value
,
'keys'
)
and
hasattr
(
section_value
,
'__getitem__'
):
if
section
[
2
]
!=
'^'
:
if
section
[
2
]
!=
'^'
:
replacer
=
self
.
_render_dictionary
(
inner
,
section_value
)
replacer
=
self
.
_render_dictionary
(
section_contents
,
section_value
)
# Lists
# Lists
elif
section_value
and
hasattr
(
section_value
,
'__iter__'
):
elif
section_value
and
hasattr
(
section_value
,
'__iter__'
):
if
section
[
2
]
!=
'^'
:
if
section
[
2
]
!=
'^'
:
replacer
=
self
.
_render_list
(
inner
,
section_value
)
replacer
=
self
.
_render_list
(
section_contents
,
section_value
)
# Other objects
# Other objects
elif
section_value
and
isinstance
(
section_value
,
object
):
elif
section_value
and
isinstance
(
section_value
,
object
):
if
section
[
2
]
!=
'^'
:
if
section
[
2
]
!=
'^'
:
replacer
=
self
.
_render_dictionary
(
inner
,
section_value
)
replacer
=
self
.
_render_dictionary
(
section_contents
,
section_value
)
# Falsey and Negated or Truthy and Not Negated
# Falsey and Negated or Truthy and Not Negated
elif
(
not
section_value
and
section
[
2
]
==
'^'
)
or
(
section_value
and
section
[
2
]
!=
'^'
):
elif
(
not
section_value
and
section
[
2
]
==
'^'
)
or
(
section_value
and
section
[
2
]
!=
'^'
):
replacer
=
self
.
_render_dictionary
(
inner
,
section_value
)
replacer
=
self
.
_render_dictionary
(
section_contents
,
section_value
)
# Render template prior to section too
# Render template prior to section too
output
=
output
+
self
.
_render_tags
(
template
[
0
:
match
.
start
()])
+
replacer
output
+=
self
.
_render_tags
(
template
[
0
:
match
.
start
()])
+
replacer
template
=
template
[
match
.
end
():]
template
=
template
[
match
.
end
():]
# Render remainder
# Render remainder
output
=
output
+
self
.
_render_tags
(
template
)
output
+=
self
.
_render_tags
(
template
)
return
output
return
output
...
...
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