@@ -15,15 +15,15 @@ syntax. For a more complete (and more current) description of Mustache's
15
15
behavior, see the official `Mustache spec `_.
16
16
17
17
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.
19
19
20
20
Logo: `David Phillips `_
21
21
22
22
23
23
Requirements
24
24
============
25
25
26
- Pystache is tested with the following versions of Python:
26
+ Pystache is tested with--
27
27
28
28
* Python 2.4 (requires simplejson `version 2.0.9 `_ or earlier)
29
29
* Python 2.5 (requires simplejson _)
@@ -49,6 +49,9 @@ Install It
49
49
::
50
50
51
51
pip install pystache
52
+ pystache-test
53
+
54
+ To install and test from source (e.g. from GitHub), see the Develop section.
52
55
53
56
54
57
Use It
@@ -74,7 +77,8 @@ Like so::
74
77
>>> from pystache.tests.examples.readme import SayHello
75
78
>>> hello = SayHello()
76
79
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)::
78
82
79
83
Hello, {{to}}!
80
84
@@ -95,9 +99,8 @@ more information.
95
99
Python 3
96
100
========
97
101
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:
101
104
102
105
* In Python 2, the default html-escape function ``cgi.escape() `` does not
103
106
escape single quotes; whereas in Python 3, the default escape function
@@ -109,14 +112,13 @@ as follows:
109
112
defaults by passing in the encodings explicitly (e.g. to the ``Renderer `` class).
110
113
111
114
112
- Unicode Handling
113
- ================
115
+ Unicode
116
+ =======
114
117
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.
117
119
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
120
122
and byte strings (``bytes `` in Python 3 and ``str `` in Python 2). For output,
121
123
Pystache's template rendering methods return only unicode.
122
124
@@ -143,26 +145,22 @@ attribute can be controlled on a per-view basis by subclassing the
143
145
default to values set in Pystache's ``defaults `` module.
144
146
145
147
146
- Test It
148
+ Develop
147
149
=======
148
150
149
- From an install-- ::
150
-
151
- pystache-test
152
-
153
- From a source distribution-- ::
151
+ To test from a source distribution (without installing)-- ::
154
152
155
153
python test_pystache.py
156
154
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 _: ::
159
157
160
158
pip install tox
161
159
tox
162
160
163
161
If you do not have all Python versions listed in ``tox.ini ``-- ::
164
162
165
- tox -e py26,py27 # for example
163
+ tox -e py26,py32 # for example
166
164
167
165
The source distribution tests also include doctests and tests from the
168
166
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-- ::
175
173
176
174
pip install pyyaml
177
175
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 _: ::
180
177
178
+ pip install nose
179
+ nosetests --tests pystache/tests/test_context.py:GetValueTests.test_dictionary__key_present
181
180
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.
184
191
185
- As of November 2011, there's a mailing list, pystache@librelist.com.
186
192
187
- Archive: http://librelist.com/browser/pystache/
193
+ Mailing List
194
+ ============
188
195
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.
191
198
192
199
193
- Author
194
- ======
200
+ Authors
201
+ =======
195
202
196
203
::
197
204
@@ -208,9 +215,11 @@ Author
208
215
.. _Distribute : http://pypi.python.org/pypi/distribute
209
216
.. _et : http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html
210
217
.. _json : http://docs.python.org/library/json.html
218
+ .. _mailing list : http://librelist.com/browser/pystache/
211
219
.. _Mustache : http://mustache.github.com/
212
220
.. _Mustache spec : https://github.com/mustache/spec
213
221
.. _mustache(5) : http://mustache.github.com/mustache.5.html
222
+ .. _nose : http://somethingaboutorange.com/mrl/projects/nose/0.11.1/testing.html
214
223
.. _only unicode strings : http://docs.python.org/howto/unicode.html#tips-for-writing-unicode-aware-programs
215
224
.. _PyPI : http://pypi.python.org/pypi/pystache
216
225
.. _Pystache : https://github.com/defunkt/pystache
@@ -221,5 +230,5 @@ Author
221
230
.. _TemplateSpec : https://github.com/defunkt/pystache/blob/master/pystache/template_spec.py
222
231
.. _test : http://packages.python.org/distribute/setuptools.html#test
223
232
.. _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
225
234
.. _version 2.0.9 : http://pypi.python.org/pypi/simplejson/2.0.9
0 commit comments