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
b80d2e94
Commit
b80d2e94
authored
May 06, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
README tweaks and added a TODO.
parent
a0feb641
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
README.rst
+7
-9
pystache/parser.py
+1
-0
No files found.
README.rst
View file @
b80d2e94
...
...
@@ -65,19 +65,18 @@ Use It
You can also create dedicated view classes to hold your view logic.
Here's your view class (in examples/readme.py)::
Here's your view class (in
.../
examples/readme.py)::
class SayHello(object):
def to(self):
return "Pizza"
L
ike so::
Instantiating l
ike so::
>>> from pystache.tests.examples.readme import SayHello
>>> hello = SayHello()
Then your template, say_hello.mustache (
in the same directory by default
Then your template, say_hello.mustache (
by default in the same directory
as your class definition)::
Hello, {{to}}!
...
...
@@ -89,16 +88,15 @@ Pull it together::
Hello, Pizza!
For greater control over rendering (e.g. to specify a custom template directory),
use the ``Renderer`` class
directly. One can pass attributes to the class's
constructor or set them on an
instance.
use the ``Renderer`` class
like above. One can pass attributes to the
Renderer class constructor or set them on a Renderer
instance.
To customize template loading on a per-view basis, subclass ``TemplateSpec``.
See the docstrings of the Renderer_ class and TemplateSpec_ class for
more information.
Try parsing
a template: ::
You can also parse
a template: ::
>>> from pystache import parse
>>> parse("Hey {{#you}}{{.}}!{{/you}}")
>>> pystache.parse("Hey {{#you}}{{.}}!{{/you}}")
['Hey ', _SectionNode(key='you', index_begin=12, index_end=18, parsed=[_EscapeNode(key='.'), '!'])]
...
...
pystache/parser.py
View file @
b80d2e94
...
...
@@ -17,6 +17,7 @@ NON_BLANK_RE = re.compile(ur'^(.)', re.M)
# TODO: add some unit tests for this.
# TODO: add a test case that checks for spurious spaces.
# TODO: add test cases for delimiters.
def
parse
(
template
,
delimiters
=
None
):
"""
Parse a unicode template string and return a ParsedTemplate instance.
...
...
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