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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
6 deletions
+15
-6
pystache/__init__.py
+1
-0
pystache/loader.py
+5
-4
pystache/template.py
+6
-2
pystache/view.py
+1
-0
setup.py
+2
-0
No files found.
pystache/__init__.py
View file @
4c22f137
...
@@ -6,3 +6,4 @@ def render(template, context=None, **kwargs):
...
@@ -6,3 +6,4 @@ def render(template, context=None, **kwargs):
context
=
context
and
context
.
copy
()
or
{}
context
=
context
and
context
.
copy
()
or
{}
context
.
update
(
kwargs
)
context
.
update
(
kwargs
)
return
Template
(
template
,
context
)
.
render
()
return
Template
(
template
,
context
)
.
render
()
pystache/loader.py
View file @
4c22f137
...
@@ -2,14 +2,15 @@ import os
...
@@ -2,14 +2,15 @@ import os
class
Loader
(
object
):
class
Loader
(
object
):
template_extension
=
'mustache'
def
__init__
(
self
,
paths
=
'.'
,
extension
=
'mustache'
,
encoding
=
None
):
template_path
=
'.'
self
.
template_paths
=
paths
template_encoding
=
None
self
.
template_extension
=
extension
self
.
template_encoding
=
encoding
def
load_template
(
self
,
template_name
,
template_dirs
=
None
,
encoding
=
None
,
extension
=
None
):
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'''
'''Returns the template string from a file or throws IOError if it non existent'''
if
None
==
template_dirs
:
if
None
==
template_dirs
:
template_dirs
=
self
.
template_path
template_dirs
=
self
.
template_path
s
if
encoding
is
not
None
:
if
encoding
is
not
None
:
self
.
template_encoding
=
encoding
self
.
template_encoding
=
encoding
...
...
pystache/template.py
View file @
4c22f137
...
@@ -45,10 +45,11 @@ class Template(object):
...
@@ -45,10 +45,11 @@ class Template(object):
modifiers
=
Modifiers
()
modifiers
=
Modifiers
()
def
__init__
(
self
,
template
=
None
,
context
=
None
,
**
kwargs
):
def
__init__
(
self
,
template
=
None
,
context
=
None
,
partials
=
None
,
**
kwargs
):
from
view
import
View
from
view
import
View
self
.
template
=
template
self
.
template
=
template
self
.
partials
=
partials
if
kwargs
:
if
kwargs
:
context
.
update
(
kwargs
)
context
.
update
(
kwargs
)
...
@@ -118,7 +119,7 @@ class Template(object):
...
@@ -118,7 +119,7 @@ class Template(object):
def
_render_dictionary
(
self
,
template
,
context
):
def
_render_dictionary
(
self
,
template
,
context
):
self
.
view
.
context_list
.
insert
(
0
,
context
)
self
.
view
.
context_list
.
insert
(
0
,
context
)
template
=
Template
(
template
,
self
.
view
)
template
=
Template
(
template
,
self
.
view
,
self
.
partials
)
out
=
template
.
render
()
out
=
template
.
render
()
self
.
view
.
context_list
.
pop
(
0
)
self
.
view
.
context_list
.
pop
(
0
)
return
out
return
out
...
@@ -149,6 +150,9 @@ class Template(object):
...
@@ -149,6 +150,9 @@ class Template(object):
@modifiers.set
(
'>'
)
@modifiers.set
(
'>'
)
def
_render_partial
(
self
,
template_name
):
def
_render_partial
(
self
,
template_name
):
if
self
.
partials
:
template
=
Template
(
self
.
partials
[
template_name
],
self
.
view
,
self
.
partials
)
else
:
from
pystache
import
Loader
from
pystache
import
Loader
markup
=
Loader
()
.
load_template
(
template_name
,
self
.
view
.
template_path
,
encoding
=
self
.
view
.
template_encoding
)
markup
=
Loader
()
.
load_template
(
template_name
,
self
.
view
.
template_path
,
encoding
=
self
.
view
.
template_encoding
)
template
=
Template
(
markup
,
self
.
view
)
template
=
Template
(
markup
,
self
.
view
)
...
...
pystache/view.py
View file @
4c22f137
...
@@ -92,3 +92,4 @@ class View(object):
...
@@ -92,3 +92,4 @@ class View(object):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
render
()
return
self
.
render
()
setup.py
View file @
4c22f137
...
@@ -25,6 +25,8 @@ setup(name='pystache',
...
@@ -25,6 +25,8 @@ setup(name='pystache',
url
=
'http://github.com/defunkt/pystache'
,
url
=
'http://github.com/defunkt/pystache'
,
packages
=
[
'pystache'
],
packages
=
[
'pystache'
],
license
=
'MIT'
,
license
=
'MIT'
,
entry_points
=
{
'console_scripts'
:
[
'pystache=pystache.commands:main'
]},
classifiers
=
(
classifiers
=
(
"Development Status :: 4 - Beta"
,
"Development Status :: 4 - Beta"
,
"License :: OSI Approved :: MIT License"
,
"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