{ "info": { "author": "Oliver Cope", "author_email": "oliver@redgecko.org", "bugtrack_url": null, "classifiers": [], "description": "Piglet Templates\n================\n\nPiglet is a text and HTML templating language in the kid/genshi/kajiki family.\n\nThe Piglet template engine offers:\n\n- Template inhertitance through py:extends/py:block (similar to Jinja2)\n- Compiles templates to fast python byte code.\n- HTML aware templating: output is well formed and content is\n escaped, preventing XSS attacks.\n- Reusable template functions, deep nesting of template inheritance,\n flexible translations and embedded python expressions\n\n`Documentation `_\n\\| `Bitbucket repository `_\n\nThis is what a piglet template looks like:\n\n.. code:: html\n\n \n\n \n

This is the content block.

\n

\n Hello $user.firstnames $user.lastname!\n

\n\n \n

\n Today is ${date.strftime('%a')}.\n

\n\n

\n \n I don't like Mondays\n \n \n I never could get the hang of Thursdays\n \n Is it the weekend yet?\n

\n\n

\n $line
\n

\n\n
\n\n\nThere's a text templating mode too:\n\n.. code::\n\n Hello $user.firstnames $user.lastname!\n\n {% trans %}\n Today is {% transname \"day\" %}${date.strftime('%a')}{% end %}\n {% end %}.\n\n {% for verse in poem %}\n {% for line in verse %}$line\n {% end %}\n {% end %}\n\n\nInstallation\n------------\n\nTo install the latest release using pip (recommended):\n\n.. code:: sh\n\n pip install piglet\n\n\nTo install the latest source:\n\n.. code:: sh\n\n hg clone https://bitbucket.org/ollyc/piglet\n cd piglet\n python setup.py install\n\n\n\nUsing Piglet templates from the Python API\n------------------------------------------\n\nA simple example of rendering a python string to a template:\n\n.. code:: python\n\n from piglet import HTMLTemplate\n\n template = HTMLTemplate('

$greeting` tags\nto indicate customization points:\n\n.. code:: html\n\n \n \n \n Default title\n \n \n \n Content goes here\n \n \n \n\n\nChild templates then use ```` to pull in the parent's\nlayout.\n\n\nYou can also define template functions:\n\n.. code:: html\n\n \n \n

\n
\n
\n
\n \n

$title

\n
\n
\n ${content() if callable(content) else content}\n
\n
\n \n \n
\n
\n
\n
\n \n\n\nTemplate functions can be imported into other templates:\n\n.. code:: html\n\n \n

\n ${widgets.modal(content=\"Hello world!\")}\n

\n\n\nDid you notice the ``${content() if callable content else content}``\ninterpolation in the function body? That's to support ``py:call``, which can\npass chunks of template code as keyword arguments:\n\n.. code:: html\n\n \n \n This is the modal content. You can include\n markup here too!\n \n \n\n\nLicense\n-------\n\nPiglet is licensed under the Apache license version 2.0.\n\n\n0.4.4 (released 2017-01-08)\n---------------------------\n\n- py:extends: allow the 'href' attribute to contain interpolations, eg\n ``\"``\n- i18n: added a babel extractor plugin for text templates\n- Bugfix: whitespace in translated strings is now correctly normalized\n- Bugfix: fixed crash in text templates when using\n ``{% if %}...{% else %}...{% end %}`` blocks\n\n0.4.3 (released 2016-11-29)\n---------------------------\n\n- Loader: an ``extension_map`` argument can be given, mapping file extensions\n to template classes. By default ``.txt`` is mapped to\n :class:`piglet.template.TextTemplate` and ``.html`` to\n :class:`piglet.template.HTMLTemplate`.\n- Bugfix: unicode symbols no longer cause an exception when used in template\n expressions in Python 2.\n- Bugfix: fixed multiple scoping issue with variable names used in\n the argument lists of ```` template function directives.\n\n0.4.2 (released 2016-11-08)\n---------------------------\n\n- Added directive\n- Exceptions are now reraised, ensuring the originating traceback is shown.\n- ```` Now passes its inner HTML as a positional argument, unless it\n is whitespace.\n- ```` is now an inner directive, meaning that\n ``

``\n will now fill the ``

`` element rather than replacing it.\n- The loader cache directory may be specified via the ``PIGLET_CACHE``\n environment variable.\n- Added i18n:comment directive\n\n0.4.1 (released 2016-10-17)\n---------------------------\n\n- Added ``{% def %}`` and ``{% for %}`` text template directives\n- Added ``allow_absolute_paths`` option to TemplateLoader\n\n0.4 (released 2016-10-16)\n-------------------------\n\n- Bugfix: ensure ```` directives are always attached to the correct\n ````\n- Added ``i18n:trans`` as an alias for i18n:translate\n- ``i18n:name`` directives now have a shorter alias\n (``i18n:s``, for substitution) and can take an optional expr attribute,\n eg ````\n- Interpolations in translated strings are now extracted using the\n interpolation text as a placeholder in the absence of a\n ``i18n:name`` directive\n- ``py:whitespace=\"strip\"`` no longer strips whitespace between tags\n on the same line.\n- Text template directives now include ``{% with %}``,\n ``{% extends %}`` and ``{% block %}``\n- can now be used to load a template of the same name elsewhere\n on the template search path.\n- The search algorithm used by TemplateLoader is improved\n- Bugfix: fix for duplicate rendering when super() is used in the middle of the\n inheritance chain\n- Generated code uses ``yield from`` where it supported by the python version.\n- The caching code has been simplified, caching .py files to disk containing\n the compiled python source.\n- Bugfix: ``py:attrs`` no longer raises an exception\n- Bugfix: interpolations can now contain entity references\n\n\n0.3 (released 2016-10-03)\n-------------------------\n\n- The translation code now normalizes whitespace in i18n:messages\n- Bugfix: fixed extraction of translations within ```` blocks\n- Added translation support in text templates\n\n0.2 (released 2016-10-02)\n-------------------------\n\n- Bugfix: ensure that grammar files are included in binary distributions\n- Bugfix: fix for undefined variable error when using py:with to reassign\n a variable\n\n0.1 (released 2016-10-01)\n-------------------------\n\n- initial release\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/ollyc/piglet", "keywords": "jinja2", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "piglet", "package_url": "https://pypi.org/project/piglet/", "platform": "", "project_url": "https://pypi.org/project/piglet/", "project_urls": { "Homepage": "https://bitbucket.org/ollyc/piglet" }, "release_url": "https://pypi.org/project/piglet/0.4.4/", "requires_dist": null, "requires_python": "", "summary": "Piglet templates: fast, HTML aware templating engine", "version": "0.4.4" }, "last_serial": 2952303, "releases": { "0": [], "0.1": [ { "comment_text": "", "digests": { "md5": "08023b354741fae5e1af348436ed09c3", "sha256": "b80297585618f624e1a27175a45ff8844992027ce38ba9d53ae5e2052b3c7663" }, "downloads": -1, "filename": "piglet-0.1.tar.gz", "has_sig": false, "md5_digest": "08023b354741fae5e1af348436ed09c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39547, "upload_time": "2016-10-01T21:51:08", "url": "https://files.pythonhosted.org/packages/af/b3/535466d64c131920e8be85f2d04f823d62127a282659a5738476ea1e5cca/piglet-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ecaaa27a32ba3dc8319804737c4edf14", "sha256": "2571e54c7cc4438c7a9dc427570776c2c3db33ab74d7c6f9de40f9869954618b" }, "downloads": -1, "filename": "piglet-0.2.tar.gz", "has_sig": false, "md5_digest": "ecaaa27a32ba3dc8319804737c4edf14", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39776, "upload_time": "2016-10-02T14:37:06", "url": "https://files.pythonhosted.org/packages/04/14/7db2e4264fc7c4029f222a96aa3f7870a1d731f1659a7e13d394d3c26e75/piglet-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "3dbaf9e6c39484219092fdf0f84a7c57", "sha256": "56e46b49c041ff8929099a79ac7c0b39bf0be40d0dbeb4a923c160a437190511" }, "downloads": -1, "filename": "piglet-0.3.tar.gz", "has_sig": false, "md5_digest": "3dbaf9e6c39484219092fdf0f84a7c57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 43880, "upload_time": "2016-10-03T14:38:23", "url": "https://files.pythonhosted.org/packages/b3/fc/b3933a07b78abfedb21a547ce830f94b0094331023d34dedcf5f750f14f6/piglet-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "159e04980e52d05f8a13de7ebe2e5071", "sha256": "c7a3d0cdb238dfecfddd915f6cd7700d0e612644f96d8052b94f0ee74ff269fd" }, "downloads": -1, "filename": "piglet-0.4.tar.gz", "has_sig": false, "md5_digest": "159e04980e52d05f8a13de7ebe2e5071", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48323, "upload_time": "2016-10-16T13:43:47", "url": "https://files.pythonhosted.org/packages/8e/8e/1dbe4068622f060ceacf190454c4527eeb22ac6a36b183bf8a1596e8a00c/piglet-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "dd52e393410abcd805727e2d38c7e500", "sha256": "21e93fc448d1ac6b3589929e560a4d9b428c9abfe1d0ed1ce0c932c6282f3f5e" }, "downloads": -1, "filename": "piglet-0.4.1.tar.gz", "has_sig": false, "md5_digest": "dd52e393410abcd805727e2d38c7e500", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48630, "upload_time": "2016-10-17T10:51:02", "url": "https://files.pythonhosted.org/packages/85/b8/c9c4f1cb55e72b3e06f5c9275f84e8b841d33ef89f180333fd7f36f2cb45/piglet-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "398c5f81dabe9dab11d8dc2ee7cb5acd", "sha256": "83bce66207fb28ab4ba992583fb162f44883c329e7bc63b7871864e37e31bd5c" }, "downloads": -1, "filename": "piglet-0.4.2.tar.gz", "has_sig": false, "md5_digest": "398c5f81dabe9dab11d8dc2ee7cb5acd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 50141, "upload_time": "2016-11-08T13:23:05", "url": "https://files.pythonhosted.org/packages/ab/a9/55e42d496b94fd62493a6321b5cf049c4b620a0b59e66def71d53ce1c96a/piglet-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "bf3146de64d38f992ae287752176dd8a", "sha256": "680e4ad8d36bb2d9f55fe2948079db8e0c6dfe874ef29ae39801d71d7d4b8035" }, "downloads": -1, "filename": "piglet-0.4.3.tar.gz", "has_sig": false, "md5_digest": "bf3146de64d38f992ae287752176dd8a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 51093, "upload_time": "2016-11-29T10:15:13", "url": "https://files.pythonhosted.org/packages/cb/66/726c4f9d0ef7d137c2483af9b455fc3c3e3f2488668b680c7b9371efcdb1/piglet-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "fe77274322330fc01184ecbedf40030e", "sha256": "3ffecb6e675f86811fc9a276a45469b742ab5b1e9e5fd7ea8e57a0934f3a9f16" }, "downloads": -1, "filename": "piglet-0.4.4.tar.gz", "has_sig": false, "md5_digest": "fe77274322330fc01184ecbedf40030e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 52355, "upload_time": "2017-01-08T21:35:10", "url": "https://files.pythonhosted.org/packages/86/f6/ef278239ebe525466ea51a7dd9d6d3211d197ac4b4abc76e17cdd419f69c/piglet-0.4.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fe77274322330fc01184ecbedf40030e", "sha256": "3ffecb6e675f86811fc9a276a45469b742ab5b1e9e5fd7ea8e57a0934f3a9f16" }, "downloads": -1, "filename": "piglet-0.4.4.tar.gz", "has_sig": false, "md5_digest": "fe77274322330fc01184ecbedf40030e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 52355, "upload_time": "2017-01-08T21:35:10", "url": "https://files.pythonhosted.org/packages/86/f6/ef278239ebe525466ea51a7dd9d6d3211d197ac4b4abc76e17cdd419f69c/piglet-0.4.4.tar.gz" } ] }