{ "info": { "author": "German Ilyin", "author_email": "germanilyin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Plugins", "Framework :: Django", "Intended Audience :: Developers", "License :: Freeware", "Programming Language :: Python :: 2.6", "Topic :: Utilities" ], "description": "WHAT IS IT?\n-----------\n\nThese templatetags is a hack making possible to insert 'content' in\nsome (maybe above the current or parent template) places.\n\nMore specifically, when we use these tags, there are some Nodes called\n'containers' that are rendered after all other nodes are rendered, but placed\nin it's right posistion. Using this hack, 'containers' may render \ndepending on variables in context that were generated by nodes placed anywhere in\ntemplate (maybe after it).\n\nIt's very useful in cases when you are reusing some template parts\nvery often. For example displaying comment list and comment submit form.\nWe write some template and put it into comments.html. Then every time \nwe need comments we just {% include \"comments.html\" %}.\nBut what if this part needs some js or css? Then we need to create \nsome comments-jscss.html and override some {% block head %}. IMHO this\nis quite inconvenient.\n\nUsing this tool we can insert js and css into head \ndirectly from comments.html \n\nMOTIVATION\n----------\n\n1. Create convenient way to include media resources in head of HTML page.\n2. Handle repetition of resource includes.\n3. Make it possible to require resources from included templates.\n4. Keep the order of resource includes from different places.\n\nINSTALL\n-------\n\n1. (required) add 'insert_above' in INSTALLED_APPS in your settings.py\n\n2. (optional) add these two lines of code somewhere in your project where\nthey will run for sure. For example in urls.py\n\n~~~~\nfrom django.template.loader import add_to_builtins\nadd_to_builtins('insert_above.templatetags.insert_tags')\n~~~~\n\nTAGS & FILTERS\n--------------\n\n1. {% insert_handler %}\n2. {% container name %}\n3. {% media_container name %}\n4. {% insert_str container str %}\n5. {% insert container %}{% endinsert %}\n6. media_tag filter simply converts `ga.js` into ``\n\nRESTRICTIONS\n------------\n\n1. `{% container %}` or `{% media_container %}` tags must NOT be in other `{% block %}`.\n2. `{% insert_handler %}` ought to be at ther very beginning of base template.\n\nVARIABLES\n---------\n\n1. `IA_USE_MEDIA_PREFIX`, by default True\n2. `IA_MEDIA_PREFIX`, if not set `STATIC_URL` is used, if not set `MEDIA_URL` is used, if not set '/media/' is used\n3. `DEBUG`, if True logs how much time spent on rendering\n4. `IA_JS_FORMAT`, by default ``\n5. `IA_CSS_FORMAT`, by default ``\n6. `IA_MEDIA_EXTENSION_FORMAT_MAP`, by default `{'css' : CSS_FORMAT, '.js' : JS_FORMAT}`\n\nEXAMPLE\n-------\n\nLet's analyze an example. \n\nbase.html\n\n~~~~{.html}\n{% insert_handler %}\n\n\n \n{% media_container media %}\n\n$(document).ready(function(){\n{% container ready %}\n});\n\n\n\n{% block content %}\n{% endblock %}\n\n\n~~~~\n\nBase template creating blocks and containers..\n\nblog/base.html\n\n~~~~{.html}\n{% extends \"base.html\" %}\n\n{% block content %}\n{% insert_str media \"js/mathjax.js\" %}\n {% block header %}{% endblock %}\n {% block menu %}{% include \"blog/menu.html\" %}{% endblock %}\n {% block text %}{% endblock %}\n {% block footer %}{% endblock %}\n{% endblock %}\n~~~~\n\nExtending content block. Requiring js/mathjax.js resource into 'media' container.\n\nblog/menu.html\n\n~~~~{.html}\n{% insert_str media \"js/animated.menu.js\" %}\n{% insert_str media \"css/animated.menu.css\" %}\n{% insert ready %}\n $('ul.menu').each(function(){\n $(this).superanimation();\n });\n{% endinsert %}\n\n~~~~\n\nRequiring js/animated.menu.js and css/animated.menu.css into \"media\" container.\nInserting javascript code into \"ready\" container.\n\nblog/post_detail.html\n\n~~~~{.html}\n{% extends \"blog/base.html\" %}\n\n{% block header %}{{ title }}{% endblock %}\n\n{% block text %}\n{% insert_str media \"js/mathjax.js\" %}\n{{ text }}\n{% endblock %}\n\n{% block footer %}\n
\n{% endblock %}\n~~~~\n\nImplementing blocks and requiring js/mathjax.js into media.\n\n\nSo if we render \nTemplate('blog/post_detail.html').render(Context({'title': 'Hello', 'text': 'World'}))\nwe will get:\n\n~~~~{.html}\n\n\n \n\n\n\n\n$(document).ready(function(){\n $('ul.menu').each(function(){\n $(this).superanimation();\n });\n});\n\n\n\nHello\n\nWorld\n
\n\n\n~~~~\n\nWhat shall be noted?\n-------------------\n\n1. `js/mathjax.js` automatically becomes ``\nand `css/animated.menu.css` becomes ``\n2. inserting from included template is possible\n3. any text may be inserted to any container. Here we insert javascript code in `$(document).ready(function(){});`\n4. `js/mathjax.js` was required twice, but included only once.\n5. The order of included resources is kept.\n\nFIXTURES\n--------\n\n### version 1.0.2\n\n + **fix MEDIA_URL setting**\n if STATIC_URL is not set in settings, it's value is None by default in new versions of Django.\n Now we check if STATIC_URL is None, then use MEDIA_URL\n\n### version 1.0.4\n\n + added new tag `{% insert_form container form %}`\n + added new tag `{% insert_form container form.media %}`\n\n## TODOs\n\n1. testing\n2. extending tags\n3. resource bulking", "description_content_type": null, "docs_url": "https://pythonhosted.org/django-insert-above/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yunmanger1/django-insert-above/", "keywords": null, "license": "WTFPL", "maintainer": null, "maintainer_email": null, "name": "django-insert-above", "package_url": "https://pypi.org/project/django-insert-above/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-insert-above/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/yunmanger1/django-insert-above/" }, "release_url": "https://pypi.org/project/django-insert-above/1.0.4/", "requires_dist": null, "requires_python": null, "summary": "These django templatetags is a hack making possible to insert \"content\" in some (maybe above the current or parent template) places.", "version": "1.0.4" }, "last_serial": 789880, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "4d0e6150929575089341c1f89698e002", "sha256": "23197f4ce3fcdddda3c6351c9ce0d694f2897275bf8608477cdca0b873bcf34c" }, "downloads": -1, "filename": "django-insert-above-1.0.tar.gz", "has_sig": false, "md5_digest": "4d0e6150929575089341c1f89698e002", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5901, "upload_time": "2011-06-16T13:04:01", "url": "https://files.pythonhosted.org/packages/f2/66/af74b1b41185601dad57bf7323381218ba4c257ca37a6a609a74494abe18/django-insert-above-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "dda4c1175d47a907c2af1f2e63d7037c", "sha256": "069813b20e846a82841bac9155be1bac36b4758a6567675ad13406bbe846f8bb" }, "downloads": -1, "filename": "django-insert-above-1.0.1.tar.gz", "has_sig": false, "md5_digest": "dda4c1175d47a907c2af1f2e63d7037c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6697, "upload_time": "2011-06-21T11:30:47", "url": "https://files.pythonhosted.org/packages/07/72/acf62cf33428a0c2a7170b67424106b3c21286e3638b3ffee3c70299f302/django-insert-above-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "5b8c94a427ee7eeb40294a8e0838e8f8", "sha256": "829181fc748168aa50581cde05781496cd8c2e10d1a03f9dc867e71fe18f71e7" }, "downloads": -1, "filename": "django-insert-above-1.0.2.tar.gz", "has_sig": false, "md5_digest": "5b8c94a427ee7eeb40294a8e0838e8f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6824, "upload_time": "2011-06-27T12:08:19", "url": "https://files.pythonhosted.org/packages/1c/1c/e3cd90af44aaade9c909087946bfedcd0b34a37129c29f6279b93703849e/django-insert-above-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "abe15d5829d8ce15c47decd8a951085f", "sha256": "7e419c93e1bb0b494447182d7fe986a53a960b107e2a8243b30a583cde27b841" }, "downloads": -1, "filename": "django-insert-above-1.0.3.tar.gz", "has_sig": false, "md5_digest": "abe15d5829d8ce15c47decd8a951085f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6812, "upload_time": "2011-06-29T10:52:38", "url": "https://files.pythonhosted.org/packages/2f/b4/0a37cdf7763b0285d678c710aaaa88be5090dea0d8c470f9217091286263/django-insert-above-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "771387b402db5c5218b7350bdb8f02eb", "sha256": "caa0e48b6ef4761091f086231e25aa07bc39729c3cf8725f17a93f968a938f27" }, "downloads": -1, "filename": "django-insert-above-1.0.4.tar.gz", "has_sig": false, "md5_digest": "771387b402db5c5218b7350bdb8f02eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7095, "upload_time": "2011-07-06T23:40:23", "url": "https://files.pythonhosted.org/packages/6a/9b/ab47c8c00980a2a1003f01b38fd89f003ec5a4df23b772c561c11eb7518c/django-insert-above-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "771387b402db5c5218b7350bdb8f02eb", "sha256": "caa0e48b6ef4761091f086231e25aa07bc39729c3cf8725f17a93f968a938f27" }, "downloads": -1, "filename": "django-insert-above-1.0.4.tar.gz", "has_sig": false, "md5_digest": "771387b402db5c5218b7350bdb8f02eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7095, "upload_time": "2011-07-06T23:40:23", "url": "https://files.pythonhosted.org/packages/6a/9b/ab47c8c00980a2a1003f01b38fd89f003ec5a4df23b772c561c11eb7518c/django-insert-above-1.0.4.tar.gz" } ] }