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
4c22f137
Commit
4c22f137
authored
Aug 04, 2011
by
vrde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok fail, forgot to add files.
parent
7667a95e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
13 deletions
+20
-13
pystache/__init__.py
+1
-0
pystache/loader.py
+6
-6
pystache/template.py
+9
-5
pystache/view.py
+2
-2
setup.py
+2
-0
No files found.
pystache/__init__.py
View file @
4c22f137
...
...
@@ -6,3 +6,4 @@ def render(template, context=None, **kwargs):
context
=
context
and
context
.
copy
()
or
{}
context
.
update
(
kwargs
)
return
Template
(
template
,
context
)
.
render
()
pystache/loader.py
View file @
4c22f137
...
...
@@ -2,14 +2,15 @@ import os
class
Loader
(
object
):
template_extension
=
'mustache'
template_path
=
'.'
template_encoding
=
None
def
__init__
(
self
,
paths
=
'.'
,
extension
=
'mustache'
,
encoding
=
None
):
self
.
template_paths
=
paths
self
.
template_extension
=
extension
self
.
template_encoding
=
encoding
def
load_template
(
self
,
template_name
,
template_dirs
=
None
,
encoding
=
None
,
extension
=
None
):
'''Returns the template string from a file or throws IOError if it non existent'''
if
None
==
template_dirs
:
template_dirs
=
self
.
template_path
template_dirs
=
self
.
template_path
s
if
encoding
is
not
None
:
self
.
template_encoding
=
encoding
...
...
@@ -44,4 +45,4 @@ class Loader(object):
finally
:
f
.
close
()
return
template
\ No newline at end of file
return
template
pystache/template.py
View file @
4c22f137
...
...
@@ -45,10 +45,11 @@ class Template(object):
modifiers
=
Modifiers
()
def
__init__
(
self
,
template
=
None
,
context
=
None
,
**
kwargs
):
def
__init__
(
self
,
template
=
None
,
context
=
None
,
partials
=
None
,
**
kwargs
):
from
view
import
View
self
.
template
=
template
self
.
partials
=
partials
if
kwargs
:
context
.
update
(
kwargs
)
...
...
@@ -118,7 +119,7 @@ class Template(object):
def
_render_dictionary
(
self
,
template
,
context
):
self
.
view
.
context_list
.
insert
(
0
,
context
)
template
=
Template
(
template
,
self
.
view
)
template
=
Template
(
template
,
self
.
view
,
self
.
partials
)
out
=
template
.
render
()
self
.
view
.
context_list
.
pop
(
0
)
return
out
...
...
@@ -149,9 +150,12 @@ class Template(object):
@modifiers.set
(
'>'
)
def
_render_partial
(
self
,
template_name
):
from
pystache
import
Loader
markup
=
Loader
()
.
load_template
(
template_name
,
self
.
view
.
template_path
,
encoding
=
self
.
view
.
template_encoding
)
template
=
Template
(
markup
,
self
.
view
)
if
self
.
partials
:
template
=
Template
(
self
.
partials
[
template_name
],
self
.
view
,
self
.
partials
)
else
:
from
pystache
import
Loader
markup
=
Loader
()
.
load_template
(
template_name
,
self
.
view
.
template_path
,
encoding
=
self
.
view
.
template_encoding
)
template
=
Template
(
markup
,
self
.
view
)
return
template
.
render
()
@modifiers.set
(
'='
)
...
...
pystache/view.py
View file @
4c22f137
...
...
@@ -91,4 +91,5 @@ class View(object):
raise
AttributeError
(
"Attribute '
%
s' does not exist in View"
%
attr
)
def
__str__
(
self
):
return
self
.
render
()
\ No newline at end of file
return
self
.
render
()
setup.py
View file @
4c22f137
...
...
@@ -25,6 +25,8 @@ setup(name='pystache',
url
=
'http://github.com/defunkt/pystache'
,
packages
=
[
'pystache'
],
license
=
'MIT'
,
entry_points
=
{
'console_scripts'
:
[
'pystache=pystache.commands:main'
]},
classifiers
=
(
"Development Status :: 4 - Beta"
,
"License :: OSI Approved :: MIT License"
,
...
...
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