summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY.rst1
-rw-r--r--README.rst6
-rw-r--r--pystache/__init__.py4
-rw-r--r--pystache/init.py1
-rw-r--r--pystache/tests/test___init__.py2
5 files changed, 11 insertions, 3 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 75b91e7..6f2c72e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -6,6 +6,7 @@ History
* Added option of raising errors on missing tags/partials:
``Renderer(missing_tags='strict')`` (issue #110).
+* Added a ``parse()`` function that yields a printable parse tree.
* Bugfix: exceptions raised from a property are no longer swallowed when
getting a key from a context stack (issue #110).
* Bugfix: lambda section values can now return non-ascii, non-unicode strings (issue #118).
diff --git a/README.rst b/README.rst
index e1b5118..a922c2d 100644
--- a/README.rst
+++ b/README.rst
@@ -95,6 +95,12 @@ 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: ::
+
+ >>> from pystache import parse
+ >>> parse("Hey {{#you}}{{.}}!{{/you}}")
+ ['Hey ', _SectionNode(key='you', index_begin=12, index_end=18, parsed=[_EscapeNode(key='.'), '!'])]
+
Python 3
========
diff --git a/pystache/__init__.py b/pystache/__init__.py
index 7548c5b..b81e912 100644
--- a/pystache/__init__.py
+++ b/pystache/__init__.py
@@ -6,8 +6,8 @@ TODO: add a docstring.
# We keep all initialization code in a separate module.
-from pystache.init import render, Renderer, TemplateSpec
+from pystache.init import parse, render, Renderer, TemplateSpec
-__all__ = ['render', 'Renderer', 'TemplateSpec']
+__all__ = ['parse', 'render', 'Renderer', 'TemplateSpec']
__version__ = '0.5.2-rc.1' # Also change in setup.py.
diff --git a/pystache/init.py b/pystache/init.py
index e9d854d..38bb1f5 100644
--- a/pystache/init.py
+++ b/pystache/init.py
@@ -5,6 +5,7 @@ This module contains the initialization logic called by __init__.py.
"""
+from pystache.parser import parse
from pystache.renderer import Renderer
from pystache.template_spec import TemplateSpec
diff --git a/pystache/tests/test___init__.py b/pystache/tests/test___init__.py
index d4f3526..eae42c1 100644
--- a/pystache/tests/test___init__.py
+++ b/pystache/tests/test___init__.py
@@ -23,7 +23,7 @@ class InitTests(unittest.TestCase):
"""
actual = set(GLOBALS_PYSTACHE_IMPORTED) - set(GLOBALS_INITIAL)
- expected = set(['render', 'Renderer', 'TemplateSpec', 'GLOBALS_INITIAL'])
+ expected = set(['parse', 'render', 'Renderer', 'TemplateSpec', 'GLOBALS_INITIAL'])
self.assertEqual(actual, expected)