{ "info": { "author": "mbello", "author_email": "mbello@users.noreply.github.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Overview\n\nJinja2 extension to enable the use of any filter as a custom autoscape filter.\n\nThis package allows you to define rules to determine when your custom autoescaping filter will be\nenabled using the same 'select_autoescape' method you already use to determine\nwhen the built-in autoescaping filter is enabled.\n\n# Usage\n from jinja2_ext_custom_autoescaping import CustomAutoescapeExtension, enable_custom_autoescaping\n from jinja2 import Environment, select_autoescape, FileSystemLoader\n\n # Your custom filter... \n def my_filter(val):\n print(val)\n if isinstance(val, str):\n return val.replace(r\"\\\\\", r\"\\\\\\\\\")\n return val\n \n \n # Here you set the rules for when the built-in autoescaping will be enabled\n built_in_select_autoescape = select_autoescape(enabled_extensions=['html', 'htm', 'xml'],\n disabled_extensions=['txt', 'tex'],\n default_for_string=True,\n default=True)\n\n # - select_autoescape is a closure\n # - enabled_extensions takes precedence over disabled_extensions, so an extension in both lists will be enabled\n # - You most likely do not want to have custom autoescaping on while built-in autoescaping is also on\n\n # Here you set the rules for when your custom autoescaping will be enabled\n custom_select_autoescape = select_autoescape(enabled_extensions=['tex', 'txt'],\n disabled_extensions=[],\n default_for_string=False,\n default=False)\n \n # Just focusing on the important parts of your Environment construction.\n env = Environment(extensions=[CustomAutoescapeExtension],\n loader=FileSystemLoader(['.']),\n autoescape=built_in_select_autoescape)\n\n opts = {'custom_select_autoescape': custom_select_autoescape,\n 'custom_autoescape_filter_name': 'my_filter',\n 'custom_autoescape_filter_func': my_filter}\n\n # Register the filter and enables autoescaping\n enable_custom_autoescaping(env, **opts)\n \n # Now you are ready to go...\n template = env.get_template('test_template.txt')\n print(template.render(var={'entry 1': 'value 1', 'entry2': r'val\\\\ue 2'}))\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mbello/jinja2-ext-custom-autoescaping", "keywords": "jinja2-ext,autoescape,autoescaping,custom autoescape", "license": "", "maintainer": "mbello", "maintainer_email": "mbello@users.noreply.github.com", "name": "jinja2-ext-custom-autoescaping", "package_url": "https://pypi.org/project/jinja2-ext-custom-autoescaping/", "platform": "", "project_url": "https://pypi.org/project/jinja2-ext-custom-autoescaping/", "project_urls": { "Homepage": "https://github.com/mbello/jinja2-ext-custom-autoescaping", "Repository": "https://github.com/mbello/jinja2-ext-custom-autoescaping" }, "release_url": "https://pypi.org/project/jinja2-ext-custom-autoescaping/0.1.0/", "requires_dist": [ "jinja2 (>=2.10,<3.0)" ], "requires_python": ">=3.6,<4.0", "summary": "Jinja2 extension to enable the use of any filter as a custom autescape filter.", "version": "0.1.0" }, "last_serial": 5552620, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "31b4da36db915f607e82d9b9f182894f", "sha256": "eea378d0acff57249c76da7f39221886a831ca164ea3a4065465668a14bbfc03" }, "downloads": -1, "filename": "jinja2_ext_custom_autoescaping-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "31b4da36db915f607e82d9b9f182894f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4550, "upload_time": "2019-02-07T15:35:23", "url": "https://files.pythonhosted.org/packages/07/c8/a5ad8411138f9df4ae1af049e6b594a89e951591481f4b22fc996b38356b/jinja2_ext_custom_autoescaping-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ecde66e0e6418bc0bd914102ac31ab0d", "sha256": "cf0bfa47b6ee914a7288002502c91e8e995d5ed6ad28f61849ee4ed9da7fb387" }, "downloads": -1, "filename": "jinja2-ext-custom-autoescaping-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ecde66e0e6418bc0bd914102ac31ab0d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 2859, "upload_time": "2019-02-07T15:35:21", "url": "https://files.pythonhosted.org/packages/d4/df/c7de0fc61715d5563ef01f662617400bffc271ac031e0427d4674303a1ee/jinja2-ext-custom-autoescaping-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "31b4da36db915f607e82d9b9f182894f", "sha256": "eea378d0acff57249c76da7f39221886a831ca164ea3a4065465668a14bbfc03" }, "downloads": -1, "filename": "jinja2_ext_custom_autoescaping-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "31b4da36db915f607e82d9b9f182894f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 4550, "upload_time": "2019-02-07T15:35:23", "url": "https://files.pythonhosted.org/packages/07/c8/a5ad8411138f9df4ae1af049e6b594a89e951591481f4b22fc996b38356b/jinja2_ext_custom_autoescaping-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ecde66e0e6418bc0bd914102ac31ab0d", "sha256": "cf0bfa47b6ee914a7288002502c91e8e995d5ed6ad28f61849ee4ed9da7fb387" }, "downloads": -1, "filename": "jinja2-ext-custom-autoescaping-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ecde66e0e6418bc0bd914102ac31ab0d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 2859, "upload_time": "2019-02-07T15:35:21", "url": "https://files.pythonhosted.org/packages/d4/df/c7de0fc61715d5563ef01f662617400bffc271ac031e0427d4674303a1ee/jinja2-ext-custom-autoescaping-0.1.0.tar.gz" } ] }