{ "info": { "author": "Nick Lourie", "author_email": "developer.nick@kozbox.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "django-macros\n=============\n\nMacros accepting positional and keyword arguments, and repeated block\ntags in the django template system. Sometimes include tags just don't\nget the job done. Either you have repeated code that you want to keep\nall in the same single template, or your code needs to dynamically\ngenerate and sub in certain values, in a way that the include syntax\ninhibits. Whatever the case, if you're finding that the built in include\ntag just isn't working for your use case, then perhaps django-macros is\nfor you.\n\nvisit the `github `__.\n\nInstallation:\n=============\n\nfrom the command line:\n\n::\n\n pip install django-macros\n\nWithin settings.py, add 'macros' to INSTALLED\\_APPS:\n\n.. code:: python\n\n INSTALLED_APPS = (\n ...\n 'macros',\n ...\n )\n\nUseage:\n=======\n\ndjango-macros contains two template tag libraries, one for creating\nmacros within templates, and one for repeating block tags.\n\nMacros Useage\n-------------\n\nExplained Useage\n~~~~~~~~~~~~~~~~\n\nAt the beginning of your file include:\n\n::\n\n {% load macros %}\n\nWhen you have a section of your template you want to repeat, but don't\nwant to have inherited or any other block tag-like functionality, define\na macro as follows:\n\n::\n\n {% macro some_macro_name arg1 arg2 kwarg=\"default\" %}\n {{ arg1 }} was the first argument.\n {{ arg2 }} was the second argument.\n\n {% if kwarg %}This is a {{ kwarg }}. {% endif %}\n {% endmacro %}\n\nThen when you want to use the macro, simply do:\n\n::\n\n {% use_macro some_macro_name \"foo\" \"bar\" kwarg=\"nondefault value\" %}\n\nwhich renders to:\n\n::\n\n foo was the first argument.\n bar was the second argument.\n This is a nondefault value.\n\nAlternatively, you can save your macros in a separate file, e.g.\n\"mymacros.html\" and load it into the template with the tag\n``{% loadmacros \"mymacros.html\" %}`` then use them with the\n``{% use_macro ... %}`` tag.\n\nAll macros, including loaded ones, are local to the template file they\nare loaded into/defined in, and are not inherited through\n``{% extends ... %}`` tags.\n\nA more in-depth useage example:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nMacro:\n^^^^^^\n\nYou can also input template variables into the macros, but filters are\nnot supported. That is, you cannot use filters in the arguments.\n\nIf the context where \\`{'foo': 'foobar'}\n\n::\n\n {% macro test2args1kwarg arg1 arg2 baz=\"Default baz\" %}\n {% firstof arg1 \"default arg1\" %}\n {% if arg2 %}{{ arg2 }}{% else %}default arg2{% endif %}\n {{ baz }}\n {% endmacro %}\n \n\n {% use_macro test2args1kwarg \"foo\" \"bar\" baz=\"KW\" %}\n
\n {% use_macro test2args1kwarg num_pages \"bar\" %}\n
\n {% use_macro test2args1kwarg %}\n\nrenders as:\n^^^^^^^^^^^\n\n::\n\n foo bar KW\n 77 bar Default baz\n default arg1 default arg2 Default baz\n\nExtended Syntax\n~~~~~~~~~~~~~~~\n\nSometimes you might want to include data that is rendered by the\ntemplate engine, or longer data containing a lot of html in a macro. For\nthis, the syntax of plugging arguments directly into the tag doesn't\nreally work, so instead of\n``{% use_macro some_macro_name \"arg\" kwarg_name=\"value\" %}``, use the\nsyntax below:\n\n::\n\n {% macro_block some_macro_name %}\n {% macro_arg %}\n arg\n {% endmacro_arg %}\n \n {% macro_kwarg kwname %}\n value\n {% endmacro_kwarg %}\n {% endmacro_block %}\n\nNote that with this syntax you no longer have to quote\nstrings/arguments. If you have a mix of longer and shorter arguments,\nyou can also use both syntaxes simultaneously:\n\n::\n\n {% macro_block some_macro_name \"arg1\" kwname1=\"value1\" %}\n {% macro_arg %}\n arg2\n {% endmacro_arg %}\n \n {% macro_kwarg kwname2 %}\n value2\n {% endmacro_kwarg %}\n {% endmacro_block %}\n\nRepeated Blocks Useage:\n-----------------------\n\nAt the beginning of your file include:\n\n::\n\n {% load repeatedblocks %}\n\nWhen you have a block that you want to repeat, instead of using a block\ntag, use a repeated block:\n\n::\n\n {% repeated_block some_block name %}\n ...\n ...\n ...\n {% endblock %}\n\nLater, when you want to repeat that block again, simply include the\nrepeat tag:\n\n::\n\n {% repeat some_block name %}\n\nThus, the following template:\n\n::\n\n {% repeated_block title %}Repeated Block Tags{% endblock %}\n\n {% repeat title %}\n\nRenders to:\n\n::\n\n Repeated Block Tags\n\n Repeated Block Tags\n\nMake sure that the ``{% repeat ... %}`` tag comes **after** the\n``{% repeated_block ... %} ... {% endblock %}`` tag.\n\nThey are fully inheritable, repeat inherited content and should work\nexactly as you'd expect a block tag to work.\n\nBonus Content!\n==============\n\nDesign Explanation for repeatedblocks.py:\n-----------------------------------------\n\nUsing a \"repeated\\_block\" followed by \"repeat\" tag structure, as opposed\nto just repeating normal block tags, forces developers to be more\nexplicit about what is repeated. Thus, it guards against the potential\nto remove block tags later in development, not realize they are\nrepeated, and create an error later. Hence, we've chosen this design\nsince it's more advantageous/pythonic in being explicit as well as dry.\n\nCredits\n=======\n\nThe macros tags are based on snippet originally by `Michal\nLudvig `__, michal@logix.cz, later modified\nfor args and kwargs by `Skylar Saveland `__.\n\nCode was updated for django 1.6, modified, and packaged by Nicholas\nLourie, while working for `kozbox, llc `__. Nick also\nadded the extended syntax to the macros.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nalourie/django-macros", "keywords": "django repeat macros macro templatetags", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "django-macros", "package_url": "https://pypi.org/project/django-macros/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-macros/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/nalourie/django-macros" }, "release_url": "https://pypi.org/project/django-macros/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "A Django template tag library for repeating blocks tags and creating in template macros.", "version": "0.4.0" }, "last_serial": 1574201, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "e06eee957ec69d3174cdca04b36dc7c7", "sha256": "fa33904e68a26c48ea4809204675594ce5e8c2efc16c2e7e47e2fa9b88da21ee" }, "downloads": -1, "filename": "django-macros-0.1.zip", "has_sig": false, "md5_digest": "e06eee957ec69d3174cdca04b36dc7c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17283, "upload_time": "2014-08-21T07:12:46", "url": "https://files.pythonhosted.org/packages/10/d1/650049d8506c685308034bbe602e9bbdb71d901c60365b41d30548801a0b/django-macros-0.1.zip" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "5a313ad20dc875f8c4ae63d8278b0ced", "sha256": "9d540d014b19b7ae4329e6a22caaeebbecb3cc1df51a6b29078e6d20c9691fc9" }, "downloads": -1, "filename": "django-macros-0.2.zip", "has_sig": false, "md5_digest": "5a313ad20dc875f8c4ae63d8278b0ced", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22246, "upload_time": "2014-08-21T07:27:01", "url": "https://files.pythonhosted.org/packages/cf/66/8b0b2e67533d432a13c8a0e656b93b8b9af5f697b4f55e236084f08c57fe/django-macros-0.2.zip" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "0968aa2cc8682cf7b45156becd5d65ad", "sha256": "9e9d684c2651fa221fab9ebe6cd7712272f253324b75a5d0be6d76811d47f65f" }, "downloads": -1, "filename": "django-macros-0.3.zip", "has_sig": false, "md5_digest": "0968aa2cc8682cf7b45156becd5d65ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22406, "upload_time": "2014-08-21T07:57:37", "url": "https://files.pythonhosted.org/packages/34/22/1edd2b53e79f9ad020558fb096e737d4b8e323bc5c4179d5a9f3eb8bf299/django-macros-0.3.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "544934d4cd8c7d36c8f7be95d8c72af5", "sha256": "e9339077ca3de6c8e5e41fa3b4d918a8b24c7379b122780ef8d3a51a07beb807" }, "downloads": -1, "filename": "django-macros-0.3.1.win32.exe", "has_sig": false, "md5_digest": "544934d4cd8c7d36c8f7be95d8c72af5", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 217447, "upload_time": "2014-09-29T20:27:51", "url": "https://files.pythonhosted.org/packages/3f/83/f08b8fd91bba91ae07a49d89156369f847ff40ee14bffed82b1922a556d3/django-macros-0.3.1.win32.exe" }, { "comment_text": "", "digests": { "md5": "b6b50c5508c990367c3576d4025f1f50", "sha256": "e188508ba86d90bc196128fd51e7ef608741ff0b2bdaf05189c1b78d4693b4c6" }, "downloads": -1, "filename": "django-macros-0.3.1.zip", "has_sig": false, "md5_digest": "b6b50c5508c990367c3576d4025f1f50", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22041, "upload_time": "2014-09-29T20:27:49", "url": "https://files.pythonhosted.org/packages/0d/44/913ef8afff01b9e68cefe3aa87cb278e8669ee9cba9003072e9a90e1ab92/django-macros-0.3.1.zip" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "f6daae1260784825f8adb0eae921eb36", "sha256": "08b91765c34aa2369f587c964935aa2804b3da93c890267147e5489d8dbd0871" }, "downloads": -1, "filename": "django-macros-0.3.2.win32.exe", "has_sig": false, "md5_digest": "f6daae1260784825f8adb0eae921eb36", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 217453, "upload_time": "2014-09-29T20:29:13", "url": "https://files.pythonhosted.org/packages/3e/55/c5d53d09468e4cc5f3adf0fdb3d62b84a37d759940a3087c351fb4221158/django-macros-0.3.2.win32.exe" }, { "comment_text": "", "digests": { "md5": "a227a7d5142048a5fd19c676b47b3c70", "sha256": "0ca1c405007165d6787ee135fb210ce62f1842962eb953923e779ea8469fe086" }, "downloads": -1, "filename": "django-macros-0.3.2.zip", "has_sig": false, "md5_digest": "a227a7d5142048a5fd19c676b47b3c70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24349, "upload_time": "2014-09-29T20:29:11", "url": "https://files.pythonhosted.org/packages/e1/0e/c27340f91933ac3c2fac86168d987c9f4b2ad405a6657253bccb51d307dd/django-macros-0.3.2.zip" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "9e8abccdaa850e58570499734fde523d", "sha256": "640af90eb7e764797ccae650d6a4a80df2e3049c59ba03adbb9c18c344a87721" }, "downloads": -1, "filename": "django-macros-0.3.3.zip", "has_sig": false, "md5_digest": "9e8abccdaa850e58570499734fde523d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24349, "upload_time": "2014-09-29T20:34:18", "url": "https://files.pythonhosted.org/packages/79/22/d6ee1cc8e3a8fc95b1b45e0aa95774ad556dd8e0cc7b2b7fe68679fbcc6a/django-macros-0.3.3.zip" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "7d9c20e75a82d7696b266a774fd3b8dd", "sha256": "2724c6dd99d4061945b92130fa857eaf3d9762f0aa175e1809479a5d7e13c1c9" }, "downloads": -1, "filename": "django-macros-0.4.0.zip", "has_sig": false, "md5_digest": "7d9c20e75a82d7696b266a774fd3b8dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25045, "upload_time": "2015-06-02T02:14:57", "url": "https://files.pythonhosted.org/packages/fd/be/9f6fcc55259c6b536d19d571dbec1577966c7c82f273f9dad157996f681c/django-macros-0.4.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7d9c20e75a82d7696b266a774fd3b8dd", "sha256": "2724c6dd99d4061945b92130fa857eaf3d9762f0aa175e1809479a5d7e13c1c9" }, "downloads": -1, "filename": "django-macros-0.4.0.zip", "has_sig": false, "md5_digest": "7d9c20e75a82d7696b266a774fd3b8dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25045, "upload_time": "2015-06-02T02:14:57", "url": "https://files.pythonhosted.org/packages/fd/be/9f6fcc55259c6b536d19d571dbec1577966c7c82f273f9dad157996f681c/django-macros-0.4.0.zip" } ] }