{ "info": { "author": "Patrick Cloke", "author_email": "clokep@patrick.cloke.us", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Django Render Block\n###################\n\n.. image:: https://travis-ci.org/clokep/django-render-block.svg?branch=master\n :target: https://travis-ci.org/clokep/django-render-block\n\nRender the content of a specific block tag from a Django template. Works for\narbitrary template inheritance, even if a block is defined in the child template\nbut not in the parent. Generally it works like ``render_to_string`` from Django,\nbut allows you to specify a block to render.\n\nFeatures\n========\n\n* Render a specific block from a template\n* Fully supports the Django templating engine\n* Partially supports the `Jinja2 `__ engine: it does\n not currently process the ``extends`` tag.\n\nRequirements\n============\n\nDjango Render Block supports Django 1.11, 2.1, and 2.2.\n\nExamples\n========\n\nIn ``test1.html``:\n\n.. code-block:: jinja\n\n {% block block1 %}block1 from test1{% endblock %}\n {% block block2 %}block2 from test1{% endblock %}\n\nIn ``test2.html``:\n\n.. code-block:: jinja\n\n {% extends 'test1.html' %}\n {% block block1 %}block1 from test2{% endblock %}\n\nAnd from the Python shell:\n\n.. code-block:: python\n\n >>> from render_block import render_block_to_string\n >>> print render_block_to_string('test2.html', 'block1')\n u'block1 from test2'\n >>> print render_block_to_string('test2.html', 'block2')\n u'block2 from test1'\n\nIt can also accept a context as a ``dict`` (just like ``render_to_string``), in\n``test3.html``:\n\n.. code-block:: jinja\n\n {% block block3 %}Render this {{ variable }}!{% endblock %}\n\nAnd from Python:\n\n.. code-block:: python\n\n >>> print render_block_to_string('test3.html', 'block3', {'variable': 'test'})\n u'Render this test!'\n\nAPI Reference\n=============\n\nThe API is simple and attempts to mirror the built-in ``render_to_string`` API.\n\n``render_block_to_string(template_name, block_name, context=None, request=None)``\n\n ``template_name``\n The name of the template to load and render. If it\u2019s a list of template\n names, Django uses ``select_template()`` instead of ``get_template()``\n to find the template.\n\n ``block_name``\n The name of the block to render from the above template.\n\n ``context``\n A ``dict`` to be used as the template\u2019s context for rendering.\n\n ``context`` is now optional. An empty context will be used if it isn\u2019t\n provided.\n\n ``request``\n The request object used to render the template.\n\n ``request`` is optional and works only for Django templates. If\n provided a ``RequestContext`` will be used instead of a ``Context``.\n\nExceptions\n----------\n\nLike ``render_to_string`` this will raise the following exceptions:\n\n ``TemplateDoesNotExists``\n Raised if the template(s) specified by ``template_name`` cannot be\n loaded.\n\n ``TemplateSyntaxError``\n Raised if the loaded template contains invalid syntax.\n\nThere are also two additional errors that can be raised:\n\n ``BlockNotFound``\n Raised if the block given by ``block_name`` does not exist in the\n template.\n\n ``UnsupportedEngine``\n Raised if a template backend besides the Django backend is used.\n\nContributing\n============\n\nIf you find a bug or have an idea for an improvement to Django Render Block,\nplease\n`file an issue `_ or\nprovide a pull request! Check the\n`list of issues `_ for\nideas of what to work on.\n\nAttribution\n===========\n\nThis is based on a few sources:\n\n* Originally `Django Snippet 769 `__\n* Updated version `Django Snippet 942 `__\n* A version of the snippets was ported as `Django-Block-Render `_\n* Additionally inspired by part of `django-templated-email `_\n* Also based on a `StackOverflow answer 2687173 `_\n\n.. :changelog:\n\nChangelog\n#########\n\n0.6 (May 8, 2019)\n=================\n\n* Supports Django 1.11, Django 2.1, and Django 2.2.\n* Supports Python 2.7, 3.5, 3.6, and 3.7.\n* ``render_block_to_string`` now optionally accepts a ``request`` parameter.\n If given a ``RequestContext`` instead of a ``Context`` is used when\n rendering with the Django templating engine. See #15, thanks to @vintage.\n\n0.5 (September 1, 2016)\n=======================\n\n* Fixes a major issue with inheriting templates and rendering a block found in\n the parent template, but overwriting part of it in the child template.\n (`#8 `_)\n\n0.4 (August 4, 2016)\n====================\n\n* Initial support for using the `Jinja2 `_ templating\n engine. See README for caveats. (`#3 `_)\n* Support Django 1.10. (`#5 `_)\n* Support Python 3. (`#6 `_)\n\n0.3.1 (June 1, 2016)\n====================\n\n* Refactoring to make more generic (for potentially supporting multiple\n templating engines).\n\n0.3 (May 27, 2016)\n==================\n\n* Largely rewritten.\n* Updated to support modern Django (1.8, 1.9):\n\n * Guards against different template backends.\n * Uses internal APIs for each node.\n * Removed ``context_instance`` parameter.\n * Support for calling ``{{ block.super }}``.\n\n0.2.2 (January 10, 2011)\n========================\n\n* Updated per\n `comment 3466 on Django Snippet 942 `_\n to fix an issue with nested extends. The specific bug was not reproducible,\n but the additional code shouldn't hurt.\n\n0.2.1 (August 27, 2010)\n=======================\n\n* Updated per\n `comment 3237 on Django Snippet 942 `_\n to remove a pointless render. The specific bug was not reproducible, but the\n code is extraneous.\n\n0.2 (August 4, 2008)\n====================\n\n* Updated version from\n `Django Snippet 942 `_ by zbyte64.\n* Improves include:\n\n 1. Simpler/better handling of \"extends\" block tag\n 2. Searches If/Else blocks\n 3. Less code\n 4. Allow list of templates to be passed which is closer to the behavior of\n render_to_response\n\n\n0.1 (May 22, 2008)\n==================\n\n* Initial version from\n `Django Snippet 769 `_ by sciyoshi.\n* Supports Django 0.96.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/clokep/django-render-block", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/clokep/django-render-block", "keywords": "django,template,block,templates,render,context", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-render-block", "package_url": "https://pypi.org/project/django-render-block/", "platform": "", "project_url": "https://pypi.org/project/django-render-block/", "project_urls": { "Download": "https://github.com/clokep/django-render-block", "Homepage": "https://github.com/clokep/django-render-block" }, "release_url": "https://pypi.org/project/django-render-block/0.6/", "requires_dist": [ "django (>=1.11)" ], "requires_python": "", "summary": "Render a particular block from a template to a string.", "version": "0.6" }, "last_serial": 5242644, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "727ab1cc44991d3daac2ab45fa12bb6e", "sha256": "7e6edddb1495d03d771d20e73865cdd7124283a01b207f44dfb5dfe716b12185" }, "downloads": -1, "filename": "django_render_block-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "727ab1cc44991d3daac2ab45fa12bb6e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17442, "upload_time": "2016-06-01T17:39:20", "url": "https://files.pythonhosted.org/packages/1f/bf/dc5d8f3efd7c101d976e52a35faa087c0c44acc0847c85c10b7047499a74/django_render_block-0.3.1-py2.py3-none-any.whl" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "363d270f368289555c82a86ec0cd50c4", "sha256": "561f6d9f889ef306b7f953bf29ebd952a2ad0f6d6659b571f7e497ece7f96185" }, "downloads": -1, "filename": "django_render_block-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "363d270f368289555c82a86ec0cd50c4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11511, "upload_time": "2016-08-04T22:33:07", "url": "https://files.pythonhosted.org/packages/26/20/ab895a61237a1b832cfd3248166023c6fc6fd328cceed99e8980852620b4/django_render_block-0.4-py2.py3-none-any.whl" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "c3aa7579fde66a81fe766b96afbef866", "sha256": "0eab0c4ef1b99ad307e1bd1bdd0daa6ee4252bc39363b1b30b29cf675b840968" }, "downloads": -1, "filename": "django_render_block-0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c3aa7579fde66a81fe766b96afbef866", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12136, "upload_time": "2016-09-01T12:15:01", "url": "https://files.pythonhosted.org/packages/43/b4/7495a352983dd20589aed780bbda6dafb7c5abe99add2accd7b04af3b94f/django_render_block-0.5-py2.py3-none-any.whl" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "5f11ed919361e9a5c3a1d7276f5a8a4c", "sha256": "95c7dc9610378a10e0c4a10d8364ec7307210889afccd6a67a6aaa0fd599bd4d" }, "downloads": -1, "filename": "django_render_block-0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f11ed919361e9a5c3a1d7276f5a8a4c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10029, "upload_time": "2019-05-08T12:18:29", "url": "https://files.pythonhosted.org/packages/1a/15/d0447101dc519bc5cdbc8eb3edf77a6ee7dd164f8ae3e0862f3f7eecf4c4/django_render_block-0.6-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5f11ed919361e9a5c3a1d7276f5a8a4c", "sha256": "95c7dc9610378a10e0c4a10d8364ec7307210889afccd6a67a6aaa0fd599bd4d" }, "downloads": -1, "filename": "django_render_block-0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f11ed919361e9a5c3a1d7276f5a8a4c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10029, "upload_time": "2019-05-08T12:18:29", "url": "https://files.pythonhosted.org/packages/1a/15/d0447101dc519bc5cdbc8eb3edf77a6ee7dd164f8ae3e0862f3f7eecf4c4/django_render_block-0.6-py2.py3-none-any.whl" } ] }