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
e6e84297
Commit
e6e84297
authored
Dec 31, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved partial tag function into Template.
parent
846b5b2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
pystache/template.py
+8
-10
No files found.
pystache/template.py
View file @
e6e84297
...
...
@@ -65,15 +65,6 @@ def render(template, view, delims=('{{', '}}')):
parse_tree
=
parse_to_tree
(
template
,
view
,
delims
)
return
render_parse_tree
(
parse_tree
,
view
,
template
)
## The possible function parse-tree elements:
def
partialTag
(
name
,
indentation
=
''
):
def
func
(
self
):
nonblank
=
re
.
compile
(
r'^(.)'
,
re
.
M
)
template
=
re
.
sub
(
nonblank
,
indentation
+
r'\1'
,
self
.
partial
(
name
))
return
render
(
template
,
self
)
return
func
def
sectionTag
(
name
,
parse_tree_
,
template_
,
delims
):
def
func
(
self
):
template
=
template_
...
...
@@ -160,6 +151,13 @@ class Template(object):
return
self
.
to_unicode
(
render
(
template
,
context
))
return
func
def
partial_tag_function
(
self
,
name
,
indentation
=
''
):
def
func
(
context
):
nonblank
=
re
.
compile
(
r'^(.)'
,
re
.
M
)
template
=
re
.
sub
(
nonblank
,
indentation
+
r'\1'
,
context
.
partial
(
name
))
return
render
(
template
,
context
)
return
func
def
parse_to_tree
(
self
,
index
=
0
):
"""
Parse a template into a syntax tree.
...
...
@@ -224,7 +222,7 @@ class Template(object):
return
end_index
if
captures
[
'tag'
]
==
'>'
:
func
=
partialTag
(
name
,
captures
[
'whitespace'
])
func
=
self
.
partial_tag_function
(
name
,
captures
[
'whitespace'
])
elif
captures
[
'tag'
]
in
[
'#'
,
'^'
]:
try
:
...
...
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