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
7667a95e
Commit
7667a95e
authored
Jul 28, 2011
by
vrde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added command line utility to render templates; partials can be passed as a dictionary
parent
b9bd807a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
pystache/commands.py
+30
-0
No files found.
pystache/commands.py
0 → 100644
View file @
7667a95e
from
pystache
import
Template
import
argparse
import
json
from
loader
import
Loader
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'Render a mustache template with the given context.'
)
parser
.
add_argument
(
'template'
,
help
=
'A filename or a template code.'
)
parser
.
add_argument
(
'context'
,
help
=
'A filename or a JSON string'
)
args
=
parser
.
parse_args
()
if
args
.
template
.
endswith
(
'.mustache'
):
args
.
template
=
args
.
template
[:
-
9
]
try
:
template
=
Loader
()
.
load_template
(
args
.
template
)
except
IOError
:
template
=
args
.
template
try
:
context
=
json
.
load
(
open
(
args
.
context
))
except
IOError
:
context
=
json
.
loads
(
args
.
context
)
print
(
Template
(
template
,
context
)
.
render
())
if
__name__
==
'__main__'
:
main
()
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