{ "info": { "author": "Livio Ribeiro", "author_email": "livioribeiro@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: CherryPy", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "============================\nlribeiro.cherrypy.templating\n============================\n\nTemplate rendering tool for cherrypy.\n\n**It does not render any template**, so you must provide a renderer for your template system to do the actual rendering.\n\nThe renderer must be a callable accepting two arguments:\n\n- The name of the template to be rendered\n- A context object, which can be a ``dict`` or any other object that your template system can handle\n\nThe template name comes from the ``@template`` decorator argument and the context is the value return from the handler.\n\nRenderer parameters\n-------------------\n\nYou can optionally pass parameters to your renderer function by just passing additional arguments to the ``@template`` decorator\n\n.. sourcecode:: python\n\n class Controller:\n @cherrypy.expose\n @template('template_name', 'some arg', some='keyword arg')\n # pass your additional parameters here\n def handler():\n pass\n\n def renderer(template_name, context, *args, **kwargs):\n # and do something with the parameters here\n pass\n\n\nDeveloped under Python3.4 and tested against Python2.7, Python3.4 and pypy.\n\nUsage:\n------\n\n.. sourcecode:: python\n\n from os import path\n\n import cherrypy\n import pystache\n\n from lribeiro.cherrypy.templating import template\n\n\n def _renderer(template_name, context):\n \"\"\"\n Template renderer using Pystache\n \"\"\"\n\n search_dir = path.join(path.dirname(path.abspath(__file__)), 'templates')\n renderer = pystache.Renderer(file_extension='html', search_dirs=search_dir)\n\n template_str = renderer.load_template(template_name)\n return renderer.render(template_str, context)\n\n\n class Root:\n @cherrypy.expose\n @template('index')\n def index(self):\n return {'name': 'Lorem', 'lastname': 'Ipsum'}\n\n @cherrypy.expose\n @template('page')\n def page(self):\n return {'name': 'Lorem', 'lastname': 'Ipsum'}\n\n @cherrypy.expose\n @template('page_with_args', 'some', 'arg')\n def page_with_args(self):\n return {'name': 'Lorem', 'lastname': 'Ipsum'}\n\n @cherrypy.expose\n @template('page_with_args', some='keyword arg')\n def page_with_args(self):\n return {'name': 'Lorem', 'lastname': 'Ipsum'}\n\n\n config = {\n '/': {\n 'templating.renderer': _renderer,\n }\n }\n\n if __name__ == '__main__':\n cherrypy.quickstart(Root(), '/', config)", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://bitbucket.org/livioribeiro/cherrypy-templating", "keywords": "templating,cherrypy,mako,jinja2,pystache,cheetah,genshi", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "lribeiro.cherrypy.templating", "package_url": "https://pypi.org/project/lribeiro.cherrypy.templating/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/lribeiro.cherrypy.templating/", "project_urls": { "Homepage": "http://bitbucket.org/livioribeiro/cherrypy-templating" }, "release_url": "https://pypi.org/project/lribeiro.cherrypy.templating/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Template rendering tool for cherrypy", "version": "1.0.1" }, "last_serial": 1220517, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "24c2f667a21e7b55af8d48c9e4fff77c", "sha256": "f725df111591fd038c250d9e16284ea9798cd1c960b8f06d05e39358e3ea1add" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "24c2f667a21e7b55af8d48c9e4fff77c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5295, "upload_time": "2014-09-08T13:25:57", "url": "https://files.pythonhosted.org/packages/d7/1a/c540b2604e260d0d0bb0f1c7a131b6c656fc8b05af13e0d7c10bf642d13b/lribeiro.cherrypy.templating-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ee2d93394fdfcd839633dfad05f9add1", "sha256": "44a327a1fc6521599f0944557cb7ea6beccbdc7429a03320b8209dd242a99537" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0.tar.gz", "has_sig": false, "md5_digest": "ee2d93394fdfcd839633dfad05f9add1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2705, "upload_time": "2014-09-08T13:25:59", "url": "https://files.pythonhosted.org/packages/1f/1e/04a4ec833fb86d07644df390fbaac29b3162fd80a78f21a775383e9ab31f/lribeiro.cherrypy.templating-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "4b38376b7c1dc5b7d8b65919d646719d", "sha256": "2d5880c04947a5ba2429874091fdc5a2c2df24288a866daf53725613901e8e08" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4b38376b7c1dc5b7d8b65919d646719d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5873, "upload_time": "2014-09-11T12:58:49", "url": "https://files.pythonhosted.org/packages/48/f2/054718478db13a8733dc271a898683380d48675ce67a44404c77524404a6/lribeiro.cherrypy.templating-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b5a98dfb1523deb34660687274589412", "sha256": "501289c5654f9363eefd1a3cb58a0787427aa0274e0e604a3e8ef4292157a966" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0.1.tar.gz", "has_sig": false, "md5_digest": "b5a98dfb1523deb34660687274589412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3071, "upload_time": "2014-09-11T12:58:47", "url": "https://files.pythonhosted.org/packages/c8/7a/9eca03386960c9c12c1382ec69e6ab9a3251d905a526b9beddbea34f79e1/lribeiro.cherrypy.templating-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4b38376b7c1dc5b7d8b65919d646719d", "sha256": "2d5880c04947a5ba2429874091fdc5a2c2df24288a866daf53725613901e8e08" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4b38376b7c1dc5b7d8b65919d646719d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5873, "upload_time": "2014-09-11T12:58:49", "url": "https://files.pythonhosted.org/packages/48/f2/054718478db13a8733dc271a898683380d48675ce67a44404c77524404a6/lribeiro.cherrypy.templating-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b5a98dfb1523deb34660687274589412", "sha256": "501289c5654f9363eefd1a3cb58a0787427aa0274e0e604a3e8ef4292157a966" }, "downloads": -1, "filename": "lribeiro.cherrypy.templating-1.0.1.tar.gz", "has_sig": false, "md5_digest": "b5a98dfb1523deb34660687274589412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3071, "upload_time": "2014-09-11T12:58:47", "url": "https://files.pythonhosted.org/packages/c8/7a/9eca03386960c9c12c1382ec69e6ab9a3251d905a526b9beddbea34f79e1/lribeiro.cherrypy.templating-1.0.1.tar.gz" } ] }