{ "info": { "author": "Dan Colish", "author_email": "chris@ozmm.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2" ], "description": "========\nPystache\n========\n\n.. image:: https://s3.amazonaws.com/webdev_bucket/pystache.png\n\nPystache_ is a Python implementation of Mustache_.\nMustache is a framework-agnostic, logic-free templating system inspired\nby ctemplate_ and et_. Like ctemplate, Mustache \"emphasizes\nseparating logic from presentation: it is impossible to embed application\nlogic in this template language.\"\n\nThe `mustache(5)`_ man page provides a good introduction to Mustache's\nsyntax. For a more complete (and more current) description of Mustache's\nbehavior, see the official `Mustache spec`_.\n\nPystache is `semantically versioned`_ and can be found on PyPI_. This\nversion of Pystache passes all tests in `version 1.1.2`_ of the spec.\n\nLogo: `David Phillips`_\n\n\nRequirements\n============\n\nPystache is tested with--\n\n* Python 2.4 (requires simplejson `version 2.0.9`_ or earlier)\n* Python 2.5 (requires simplejson_)\n* Python 2.6\n* Python 2.7\n* Python 3.1\n* Python 3.2\n\nJSON support is needed only for the command-line interface and to run the\nspec tests. We require simplejson for earlier versions of Python since\nPython's json_ module was added in Python 2.6.\n\nFor Python 2.4 we require an earlier version of simplejson since simplejson\nstopped officially supporting Python 2.4 in simplejson version 2.1.0.\nEarlier versions of simplejson can be installed manually, as follows: ::\n\n pip install 'simplejson<2.1.0'\n\n\nInstall It\n==========\n\n::\n\n pip install pystache\n pystache-test\n\nTo install and test from source (e.g. from GitHub), see the Develop section.\n\n\nUse It\n======\n\n::\n\n >>> import pystache\n >>> print pystache.render('Hi {{person}}!', {'person': 'Mom'})\n Hi Mom!\n\nYou can also create dedicated view classes to hold your view logic.\n\nHere's your view class (in examples/readme.py)::\n\n class SayHello(object):\n\n def to(self):\n return \"Pizza\"\n\nLike so::\n\n >>> from pystache.tests.examples.readme import SayHello\n >>> hello = SayHello()\n\nThen your template, say_hello.mustache (in the same directory by default\nas your class definition)::\n\n Hello, {{to}}!\n\nPull it together::\n\n >>> renderer = pystache.Renderer()\n >>> print renderer.render(hello)\n Hello, Pizza!\n\nFor greater control over rendering (e.g. to specify a custom template directory),\nuse the ``Renderer`` class directly. One can pass attributes to the class's\nconstructor or set them on an instance.\nTo customize template loading on a per-view basis, subclass ``TemplateSpec``.\nSee the docstrings of the Renderer_ class and TemplateSpec_ class for\nmore information.\n\n\nPython 3\n========\n\nPystache has supported Python 3 since version 0.5.1. Pystache behaves\nslightly differently between Python 2 and 3, as follows:\n\n* In Python 2, the default html-escape function ``cgi.escape()`` does not\n escape single quotes; whereas in Python 3, the default escape function\n ``html.escape()`` does escape single quotes.\n* In both Python 2 and 3, the string and file encodings default to\n ``sys.getdefaultencoding()``. However, this function can return different\n values under Python 2 and 3, even when run from the same system. Check\n your own system for the behavior on your system, or do not rely on the\n defaults by passing in the encodings explicitly (e.g. to the ``Renderer`` class).\n\n\nUnicode\n=======\n\nThis section describes how Pystache handles unicode, strings, and encodings.\n\nInternally, Pystache uses `only unicode strings`_ (``str`` in Python 3 and\n``unicode`` in Python 2). For input, Pystache accepts both unicode strings\nand byte strings (``bytes`` in Python 3 and ``str`` in Python 2). For output,\nPystache's template rendering methods return only unicode.\n\nPystache's ``Renderer`` class supports a number of attributes to control how\nPystache converts byte strings to unicode on input. These include the\n``file_encoding``, ``string_encoding``, and ``decode_errors`` attributes.\n\nThe ``file_encoding`` attribute is the encoding the renderer uses to convert\nto unicode any files read from the file system. Similarly, ``string_encoding``\nis the encoding the renderer uses to convert any other byte strings encountered\nduring the rendering process into unicode (e.g. context values that are\nencoded byte strings).\n\nThe ``decode_errors`` attribute is what the renderer passes as the ``errors``\nargument to Python's built-in unicode-decoding function (``str()`` in Python 3\nand ``unicode()`` in Python 2). The valid values for this argument are\n``strict``, ``ignore``, and ``replace``.\n\nEach of these attributes can be set via the ``Renderer`` class's constructor\nusing a keyword argument of the same name. See the Renderer class's\ndocstrings for further details. In addition, the ``file_encoding``\nattribute can be controlled on a per-view basis by subclassing the\n``TemplateSpec`` class. When not specified explicitly, these attributes\ndefault to values set in Pystache's ``defaults`` module.\n\n\nDevelop\n=======\n\nTo test from a source distribution (without installing)-- ::\n\n python test_pystache.py\n\nTo test Pystache with multiple versions of Python (with a single command!),\nyou can use tox_: ::\n\n pip install tox\n tox\n\nIf you do not have all Python versions listed in ``tox.ini``-- ::\n\n tox -e py26,py32 # for example\n\nThe source distribution tests also include doctests and tests from the\nMustache spec. To include tests from the Mustache spec in your test runs: ::\n\n git submodule init\n git submodule update\n\nThe test harness parses the spec's (more human-readable) yaml files if PyYAML_\nis present. Otherwise, it parses the json files. To install PyYAML-- ::\n\n pip install pyyaml\n\nTo run a subset of the tests, you can use nose_: ::\n\n pip install nose\n nosetests --tests pystache/tests/test_context.py:GetValueTests.test_dictionary__key_present\n\n**Running Pystache from source with Python 3.** Pystache is written in\nPython 2 and must be converted with 2to3_ prior to running under Python 3.\nThe installation process (and tox) do this conversion automatically.\n\nTo ``import pystache`` from a source distribution while using Python 3,\nbe sure that you are importing from a directory containing a converted\nversion (e.g. from your site-packages directory after manually installing)\nand not from the original source directory. Otherwise, you will get a\nsyntax error. You can help ensure this by not running the Python IDE\nfrom the project directory when importing Pystache.\n\n\nMailing List\n============\n\nThere is a `mailing list`_. Note that there is a bit of a delay between\nposting a message and seeing it appear in the mailing list archive.\n\n\nAuthors\n=======\n\n::\n\n >>> context = { 'author': 'Chris Wanstrath', 'maintainer': 'Chris Jerdonek' }\n >>> print pystache.render(\"Author: {{author}}\\nMaintainer: {{maintainer}}\", context)\n Author: Chris Wanstrath\n Maintainer: Chris Jerdonek\n\n\n.. _2to3: http://docs.python.org/library/2to3.html\n.. _built-in unicode function: http://docs.python.org/library/functions.html#unicode\n.. _ctemplate: http://code.google.com/p/google-ctemplate/\n.. _David Phillips: http://davidphillips.us/\n.. _Distribute: http://pypi.python.org/pypi/distribute\n.. _et: http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html\n.. _json: http://docs.python.org/library/json.html\n.. _mailing list: http://librelist.com/browser/pystache/\n.. _Mustache: http://mustache.github.com/\n.. _Mustache spec: https://github.com/mustache/spec\n.. _mustache(5): http://mustache.github.com/mustache.5.html\n.. _nose: http://somethingaboutorange.com/mrl/projects/nose/0.11.1/testing.html\n.. _only unicode strings: http://docs.python.org/howto/unicode.html#tips-for-writing-unicode-aware-programs\n.. _PyPI: http://pypi.python.org/pypi/pystache\n.. _Pystache: https://github.com/defunkt/pystache\n.. _PyYAML: http://pypi.python.org/pypi/PyYAML\n.. _Renderer: https://github.com/defunkt/pystache/blob/master/pystache/renderer.py\n.. _semantically versioned: http://semver.org\n.. _simplejson: http://pypi.python.org/pypi/simplejson/\n.. _TemplateSpec: https://github.com/defunkt/pystache/blob/master/pystache/template_spec.py\n.. _test: http://packages.python.org/distribute/setuptools.html#test\n.. _tox: http://pypi.python.org/pypi/tox\n.. _version 1.1.2: https://github.com/mustache/spec/tree/v1.1.2\n.. _version 2.0.9: http://pypi.python.org/pypi/simplejson/2.0.9\n\n\nHistory\n=======\n\n0.5.2 (2012-05-03)\n------------------\n\n* Added support for dot notation and version 1.1.2 of the spec (issue #99). [rbp]\n* Missing partials now render as empty string per latest version of spec (issue #115).\n* Bugfix: falsey values now coerced to strings using str().\n* Bugfix: lambda return values for sections no longer pushed onto context stack (issue #113).\n* Bugfix: lists of lambdas for sections were not rendered (issue #114).\n\n0.5.1 (2012-04-24)\n------------------\n\n* Added support for Python 3.1 and 3.2.\n* Added tox support to test multiple Python versions.\n* Added test script entry point: pystache-test.\n* Added __version__ package attribute.\n* Test harness now supports both YAML and JSON forms of Mustache spec.\n* Test harness no longer requires nose.\n\n0.5.0 (2012-04-03)\n------------------\n\nThis version represents a major rewrite and refactoring of the code base\nthat also adds features and fixes many bugs. All functionality and nearly\nall unit tests have been preserved. However, some backwards incompatible\nchanges to the API have been made.\n\nBelow is a selection of some of the changes (not exhaustive).\n\nHighlights:\n\n* Pystache now passes all tests in version 1.0.3 of the `Mustache spec`_. [pvande]\n* Removed View class: it is no longer necessary to subclass from View or\n from any other class to create a view.\n* Replaced Template with Renderer class: template rendering behavior can be\n modified via the Renderer constructor or by setting attributes on a Renderer instance.\n* Added TemplateSpec class: template rendering can be specified on a per-view\n basis by subclassing from TemplateSpec.\n* Introduced separation of concerns and removed circular dependencies (e.g.\n between Template and View classes, cf. `issue #13`_).\n* Unicode now used consistently throughout the rendering process.\n* Expanded test coverage: nosetests now runs doctests and ~105 test cases\n from the Mustache spec (increasing the number of tests from 56 to ~315).\n* Added a rudimentary benchmarking script to gauge performance while refactoring.\n* Extensive documentation added (e.g. docstrings).\n\nOther changes:\n\n* Added a command-line interface. [vrde]\n* The main rendering class now accepts a custom partial loader (e.g. a dictionary)\n and a custom escape function.\n* Non-ascii characters in str strings are now supported while rendering.\n* Added string encoding, file encoding, and errors options for decoding to unicode.\n* Removed the output encoding option.\n* Removed the use of markupsafe.\n\nBug fixes:\n\n* Context values no longer processed as template strings. [jakearchibald]\n* Whitespace surrounding sections is no longer altered, per the spec. [heliodor]\n* Zeroes now render correctly when using PyPy. [alex]\n* Multline comments now permitted. [fczuardi]\n* Extensionless template files are now supported.\n* Passing ``**kwargs`` to ``Template()`` no longer modifies the context.\n* Passing ``**kwargs`` to ``Template()`` with no context no longer raises an exception.\n\n0.4.1 (2012-03-25)\n------------------\n* Added support for Python 2.4. [wangtz, jvantuyl]\n\n0.4.0 (2011-01-12)\n------------------\n* Add support for nested contexts (within template and view)\n* Add support for inverted lists\n* Decoupled template loading\n\n0.3.1 (2010-05-07)\n------------------\n\n* Fix package\n\n0.3.0 (2010-05-03)\n------------------\n\n* View.template_path can now hold a list of path\n* Add {{& blah}} as an alias for {{{ blah }}}\n* Higher Order Sections\n* Inverted sections\n\n0.2.0 (2010-02-15)\n------------------\n\n* Bugfix: Methods returning False or None are not rendered\n* Bugfix: Don't render an empty string when a tag's value is 0. [enaeseth]\n* Add support for using non-callables as View attributes. [joshthecoder]\n* Allow using View instances as attributes. [joshthecoder]\n* Support for Unicode and non-ASCII-encoded bytestring output. [enaeseth]\n* Template file encoding awareness. [enaeseth]\n\n0.1.1 (2009-11-13)\n------------------\n\n* Ensure we're dealing with strings, always\n* Tests can be run by executing the test file directly\n\n0.1.0 (2009-11-12)\n------------------\n\n* First release\n\n\n.. _2to3: http://docs.python.org/library/2to3.html\n.. _issue #13: https://github.com/defunkt/pystache/issues/13\n.. _Mustache spec: https://github.com/mustache/spec\n\n\nLicense\n=======\n\nCopyright (C) 2012 Chris Jerdonek. All rights reserved.\nCopyright (c) 2009 Chris Wanstrath\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/dcolish/braces", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "braces", "package_url": "https://pypi.org/project/braces/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/braces/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/dcolish/braces" }, "release_url": "https://pypi.org/project/braces/0.5.2/", "requires_dist": null, "requires_python": null, "summary": "Mustache for Python", "version": "0.5.2" }, "last_serial": 444074, "releases": { "0.5.2": [] }, "urls": [] }