{ "info": { "author": "Jared Newell", "author_email": "jared.newell@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Framework :: Django :: 1.10", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "=============================\ndjango-n3-templateplugins\n=============================\n\n.. image:: https://badge.fury.io/py/dj-n3-templateplugins.svg\n :target: https://badge.fury.io/py/dj-n3-templateplugins\n\n.. image:: https://travis-ci.org/Jaredn/dj-n3-templateplugins.svg?branch=master\n :target: https://travis-ci.org/Jaredn/dj-n3-templateplugins\n\n.. image:: https://codecov.io/gh/Jaredn/dj-n3-templateplugins/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/Jaredn/dj-n3-templateplugins\n\nExtensible Template Plugins for Django\n\nDocumentation\n-------------\n\nThe full documentation is at https://dj-n3-templateplugins.readthedocs.io.\n\nQuickstart\n----------\n\nInstall django-n3-templateplugins::\n\n pip install dj-n3-templateplugins\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n INSTALLED_APPS = (\n ...\n 'dj_n3_templateplugins.apps.DjN3TemplatepluginsConfig',\n ...\n )\n\nFeatures\n--------\n\nIf you want to build an extensible platform, you may find the need to allow the developers that use your app to alter\nor add on to the functionality that you provide. This django package attempts to add 'plugin' functionality to\nyour django app.\n\nTo give an example of why I'm creating this... My company built an in-house django asset management system that we want to open-source, but there is a bunch of business-logic throughout the Templates and Views that wouldn't make sense in an open-sourced app. So in order to open source our asset management system we needed to make our custom business-logic pluggable. Plus, anyone that used our asset management system would probably want a similar feature for their own business logic.\n\nHow it works:\n\nEnd-Users of your app create a 'plugin', which is just a Python Class which requires two methods to be created:\n\n.. code-block:: python\n\n # plugin.py\n class Plugin(TemplatePlugin):\n def get_context_data():\n # How the plugin adds extra data to your Views/Templates\n return {'foo': 'some context'}\n\n def render_html():\n # How the plugin uses the context (and any provided by your view) to return HTML code (Full Django Template\n # syntax is allowed here!)\n return '

I am HTML and I can use my context like this: {{ plugins.plugin_name.context.foo }}

'\n\n\nThese plugins get placed in the configurable directory:\n\n.. code-block:: python\n\n # settings.py\n N3PLUGINS_PLUGIN_DIR = '/some/path/with/plugins'\n\n\nYou then use the provided decorator @load_plugins to decorate your views like this:\n\n.. code-block:: python\n\n # views.py\n @load_plugins\n class TestView(ListView):\n model = SomeModel\n template_name = 'some_template.html'\n\n def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['plugins'] = self.plugins\n return context\n\nThis decorator will set a class property called self.plugins which is a dictionary. You then use this at any point\nin your view's code and make sure it gets added to the Context object that is passed in for Template rendering.\n\n\nIn your template you then use django-n3-templateplugins provided templatetag to render the plugin's html, which looks\nsomething like this:\n\n.. code-block:: python\n\n # some_template.html\n {% load render_plugin %}\n {% for k, v in plugins.items %}\n {% render_plugin v.plugin_object %}\n {% endfor %}\n\nAnd that's it!\n\n* TODO\n* Note: This early implementation only works with class-based views (as we set a class property with a decorator. This\nisn't possible with a function).\n\nRunning Tests\n-------------\n\nDoes the code actually work?\n\n::\n\n source /bin/activate\n (myenv) $ pip install tox\n (myenv) $ tox\n\nCredits\n-------\n\nTools used in rendering this package:\n\n* Cookiecutter_\n* `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n\n\n\n\nHistory\n-------\n\n0.1.0 (2017-09-16)\n++++++++++++++++++\n\n* First release on PyPI.\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/Jaredn/dj-n3-templateplugins/archive/0.3.1.tar.giz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Jaredn/dj-n3-templateplugins", "keywords": "dj-n3-templateplugins django plugins template templateplugin", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dj-n3-templateplugins", "package_url": "https://pypi.org/project/dj-n3-templateplugins/", "platform": "", "project_url": "https://pypi.org/project/dj-n3-templateplugins/", "project_urls": { "Download": "https://github.com/Jaredn/dj-n3-templateplugins/archive/0.3.1.tar.giz", "Homepage": "https://github.com/Jaredn/dj-n3-templateplugins" }, "release_url": "https://pypi.org/project/dj-n3-templateplugins/0.3.1/", "requires_dist": null, "requires_python": "", "summary": "Extensible Template Plugins for Django", "version": "0.3.1" }, "last_serial": 3193699, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "14d8bd88853922b0515807cd2a056904", "sha256": "f1c341c3b0d55bf7b38cff5b8a1067140d54c8a52f9f552297294dd8c7223631" }, "downloads": -1, "filename": "dj-n3-templateplugins-0.2.0.tar.gz", "has_sig": false, "md5_digest": "14d8bd88853922b0515807cd2a056904", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8632, "upload_time": "2017-09-21T04:34:37", "url": "https://files.pythonhosted.org/packages/1b/7c/bc8e6cf27a39bf74a069e6d905661b7e8e0c7555a96744d0edbc9b8cdff8/dj-n3-templateplugins-0.2.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "87f70acf5f2ee4ac67e651923f1427ce", "sha256": "def536b2cb874e150dab2db9ea37f57d8e4d0d8235ce89c6544bb8402530a282" }, "downloads": -1, "filename": "dj-n3-templateplugins-0.3.1.tar.gz", "has_sig": false, "md5_digest": "87f70acf5f2ee4ac67e651923f1427ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8927, "upload_time": "2017-09-22T05:34:41", "url": "https://files.pythonhosted.org/packages/32/8b/fe56df1d8b4f376215a042a962d61fd7bc7149df827df65895dccae7090f/dj-n3-templateplugins-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87f70acf5f2ee4ac67e651923f1427ce", "sha256": "def536b2cb874e150dab2db9ea37f57d8e4d0d8235ce89c6544bb8402530a282" }, "downloads": -1, "filename": "dj-n3-templateplugins-0.3.1.tar.gz", "has_sig": false, "md5_digest": "87f70acf5f2ee4ac67e651923f1427ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8927, "upload_time": "2017-09-22T05:34:41", "url": "https://files.pythonhosted.org/packages/32/8b/fe56df1d8b4f376215a042a962d61fd7bc7149df827df65895dccae7090f/dj-n3-templateplugins-0.3.1.tar.gz" } ] }