Skip to content

Commit 8bc8baf

Browse files
committed
Merge branch 'development' into 'master': staging v0.5.2-rc
2 parents cc262ab + 3c83934 commit 8bc8baf

25 files changed

+702
-221
lines changed

HISTORY.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
History
22
=======
33

4+
0.5.2 (2012-05-03)
5+
------------------
6+
7+
* Added support for dot notation and version 1.1.2 of the spec (issue #99). [rbp]
8+
* Missing partials now render as empty string per latest version of spec (issue #115).
9+
* Bugfix: falsey values now coerced to strings using str().
10+
* Bugfix: lambda return values for sections no longer pushed onto context stack (issue #113).
11+
* Bugfix: lists of lambdas for sections were not rendered (issue #114).
12+
413
0.5.1 (2012-04-24)
514
------------------
615

README.rst

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ syntax. For a more complete (and more current) description of Mustache's
1515
behavior, see the official `Mustache spec`_.
1616

1717
Pystache is `semantically versioned`_ and can be found on PyPI_. This
18-
version of Pystache passes all tests in `version 1.0.3`_ of the spec.
18+
version of Pystache passes all tests in `version 1.1.2`_ of the spec.
1919

2020
Logo: `David Phillips`_
2121

2222

2323
Requirements
2424
============
2525

26-
Pystache is tested with the following versions of Python:
26+
Pystache is tested with--
2727

2828
* Python 2.4 (requires simplejson `version 2.0.9`_ or earlier)
2929
* Python 2.5 (requires simplejson_)
@@ -49,6 +49,9 @@ Install It
4949
::
5050

5151
pip install pystache
52+
pystache-test
53+
54+
To install and test from source (e.g. from GitHub), see the Develop section.
5255

5356

5457
Use It
@@ -74,7 +77,8 @@ Like so::
7477
>>> from pystache.tests.examples.readme import SayHello
7578
>>> hello = SayHello()
7679

77-
Then your template, say_hello.mustache (by default in the same directory)::
80+
Then your template, say_hello.mustache (in the same directory by default
81+
as your class definition)::
7882

7983
Hello, {{to}}!
8084

@@ -95,9 +99,8 @@ more information.
9599
Python 3
96100
========
97101

98-
As of version 0.5.1, Pystache fully supports Python 3. There are slight
99-
differences in behavior between Pystache running under Python 2 and 3,
100-
as follows:
102+
Pystache has supported Python 3 since version 0.5.1. Pystache behaves
103+
slightly differently between Python 2 and 3, as follows:
101104

102105
* In Python 2, the default html-escape function ``cgi.escape()`` does not
103106
escape single quotes; whereas in Python 3, the default escape function
@@ -109,14 +112,13 @@ as follows:
109112
defaults by passing in the encodings explicitly (e.g. to the ``Renderer`` class).
110113

111114

112-
Unicode Handling
113-
================
115+
Unicode
116+
=======
114117

115-
This section describes Pystache's handling of unicode (e.g. strings and
116-
encodings).
118+
This section describes how Pystache handles unicode, strings, and encodings.
117119

118-
Internally, Pystache uses `only unicode strings`_ (type ``str`` in Python 3 and
119-
type ``unicode`` in Python 2). For input, Pystache accepts both unicode strings
120+
Internally, Pystache uses `only unicode strings`_ (``str`` in Python 3 and
121+
``unicode`` in Python 2). For input, Pystache accepts both unicode strings
120122
and byte strings (``bytes`` in Python 3 and ``str`` in Python 2). For output,
121123
Pystache's template rendering methods return only unicode.
122124

@@ -143,26 +145,22 @@ attribute can be controlled on a per-view basis by subclassing the
143145
default to values set in Pystache's ``defaults`` module.
144146

145147

146-
Test It
148+
Develop
147149
=======
148150

149-
From an install-- ::
150-
151-
pystache-test
152-
153-
From a source distribution-- ::
151+
To test from a source distribution (without installing)-- ::
154152

155153
python test_pystache.py
156154

157-
To test Pystache source under multiple versions of Python all at once, you
158-
can use tox_: ::
155+
To test Pystache with multiple versions of Python (with a single command!),
156+
you can use tox_: ::
159157

160158
pip install tox
161159
tox
162160

163161
If you do not have all Python versions listed in ``tox.ini``-- ::
164162

165-
tox -e py26,py27 # for example
163+
tox -e py26,py32 # for example
166164

167165
The source distribution tests also include doctests and tests from the
168166
Mustache spec. To include tests from the Mustache spec in your test runs: ::
@@ -175,23 +173,32 @@ is present. Otherwise, it parses the json files. To install PyYAML-- ::
175173

176174
pip install pyyaml
177175

178-
To test Pystache from a source distribution with Python 3.x, you must use tox.
179-
This is because the source code must first be run through 2to3_.
176+
To run a subset of the tests, you can use nose_: ::
180177

178+
pip install nose
179+
nosetests --tests pystache/tests/test_context.py:GetValueTests.test_dictionary__key_present
181180

182-
Mailing List
183-
============
181+
**Running Pystache from source with Python 3.** Pystache is written in
182+
Python 2 and must be converted with 2to3_ prior to running under Python 3.
183+
The installation process (and tox) do this conversion automatically.
184+
185+
To ``import pystache`` from a source distribution while using Python 3,
186+
be sure that you are importing from a directory containing a converted
187+
version (e.g. from your site-packages directory after manually installing)
188+
and not from the original source directory. Otherwise, you will get a
189+
syntax error. You can help ensure this by not running the Python IDE
190+
from the project directory when importing Pystache.
184191

185-
As of November 2011, there's a mailing list, pystache@librelist.com.
186192

187-
Archive: http://librelist.com/browser/pystache/
193+
Mailing List
194+
============
188195

189-
Note: There's a bit of a delay in seeing the latest emails appear
190-
in the archive.
196+
There is a `mailing list`_. Note that there is a bit of a delay between
197+
posting a message and seeing it appear in the mailing list archive.
191198

192199

193-
Author
194-
======
200+
Authors
201+
=======
195202

196203
::
197204

@@ -208,9 +215,11 @@ Author
208215
.. _Distribute: http://pypi.python.org/pypi/distribute
209216
.. _et: http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html
210217
.. _json: http://docs.python.org/library/json.html
218+
.. _mailing list: http://librelist.com/browser/pystache/
211219
.. _Mustache: http://mustache.github.com/
212220
.. _Mustache spec: https://github.com/mustache/spec
213221
.. _mustache(5): http://mustache.github.com/mustache.5.html
222+
.. _nose: http://somethingaboutorange.com/mrl/projects/nose/0.11.1/testing.html
214223
.. _only unicode strings: http://docs.python.org/howto/unicode.html#tips-for-writing-unicode-aware-programs
215224
.. _PyPI: http://pypi.python.org/pypi/pystache
216225
.. _Pystache: https://github.com/defunkt/pystache
@@ -221,5 +230,5 @@ Author
221230
.. _TemplateSpec: https://github.com/defunkt/pystache/blob/master/pystache/template_spec.py
222231
.. _test: http://packages.python.org/distribute/setuptools.html#test
223232
.. _tox: http://pypi.python.org/pypi/tox
224-
.. _version 1.0.3: https://github.com/mustache/spec/tree/48c933b0bb780875acbfd15816297e263c53d6f7
233+
.. _version 1.1.2: https://github.com/mustache/spec/tree/v1.1.2
225234
.. _version 2.0.9: http://pypi.python.org/pypi/simplejson/2.0.9

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ TODO
44
* Turn the benchmarking script at pystache/tests/benchmark.py into a command in pystache/commands, or
55
make it a subcommand of one of the existing commands (i.e. using a command argument).
66
* Provide support for logging in at least one of the commands.
7-
* Make sure doctest text files can be converted for Python 3 when using tox.
87
* Make sure command parsing to pystache-test doesn't break with Python 2.4 and earlier.
98
* Combine pystache-test with the main command.

pystache/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
__all__ = ['render', 'Renderer', 'TemplateSpec']
1212

13-
__version__ = '0.5.1' # Also change in setup.py.
13+
__version__ = '0.5.2-rc' # Also change in setup.py.

pystache/commands/render.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#
3636
# ValueError: Attempted relative import in non-package
3737
#
38+
from pystache.common import TemplateNotFoundError
3839
from pystache.renderer import Renderer
3940

4041

@@ -78,7 +79,7 @@ def main(sys_argv=sys.argv):
7879

7980
try:
8081
template = renderer.load_template(template)
81-
except IOError:
82+
except TemplateNotFoundError:
8283
pass
8384

8485
try:

pystache/commands/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import sys
99

10-
from pystache.tests.main import run_tests
10+
from pystache.tests.main import main as run_tests
1111

1212

1313
def main(sys_argv=sys.argv):

pystache/common.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf-8
22

33
"""
4-
Exposes common functions.
4+
Exposes functionality needed throughout the project.
55
66
"""
77

@@ -24,3 +24,13 @@ def read(path):
2424
return f.read()
2525
finally:
2626
f.close()
27+
28+
29+
class PystacheError(Exception):
30+
"""Base class for Pystache exceptions."""
31+
pass
32+
33+
34+
class TemplateNotFoundError(PystacheError):
35+
"""An exception raised when a template is not found."""
36+
pass

0 commit comments

Comments
 (0)