telegrinder-templating


Nametelegrinder-templating JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/luwqz1/telegrinder_templating
SummaryThis module is intended for the Telegrinder framework. It allows for text templating.
upload_time2023-08-30 17:55:31
maintainer
docs_urlNone
authorGeogry howl
requires_python>=3.11,<4.0
licenseMIT
keywords python telegrinder framework tool templating telegrinder tool jinja2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # telegrinder templating tool

This module is used with telegrinder framework. It is used to create text templates.

Install using PyPI:

```
pip install telegrinder-templating
```


# Documentation

There is templating in order to avoid using large text. Module `telegrinder_templating` has an `ABCTemplating` interface for creating templating classes.

```python
from telegrinder_templating import ABCTemplating
```

`telegrinder_templating` has class `JinjaTemplating` to work with jinja templates.

```python
from telegrinder_templating import JinjaTemplating
```

`JinjaTemplating` methods:
* `render(template_name: str, **data: Any) -> str`
* `render_from_string(template_source: str, **data: Any) -> str`
* `@add_filter(key: str | None) -> wrapper(func: JinjaFilter)`


Example:
```python
import asyncio
import pathlib

import jinja2

from telegrinder_templating import JinjaTemplating

jt = JinjaTemplating(pathlib.Path(__file__).resolve().parent / "templates")


@jt.add_filter("title")
def title_string(value: str, must_strip: bool = False) -> str:
    if must_strip:
        return value.strip().title()
    return value.title()


async def main():
    await jt.render("template.j2", digits=[1, 2, 3])
    await jt.render_from_string("{{ name|title(must_strip=True) }}", name="  alex")


asyncio.run(main())
```

More details about `Jinja` can be found [*HERE*](https://jinja.palletsprojects.com/en)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/luwqz1/telegrinder_templating",
    "name": "telegrinder-templating",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "python,telegrinder framework,tool,templating,telegrinder tool,jinja2",
    "author": "Geogry howl",
    "author_email": "howluwqz1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/86/49641030eb3bf83523a32850d03ea2577a6d7b62f86130e2ebe8104c61f0/telegrinder_templating-1.0.3.tar.gz",
    "platform": null,
    "description": "# telegrinder templating tool\n\nThis module is used with telegrinder framework. It is used to create text templates.\n\nInstall using PyPI:\n\n```\npip install telegrinder-templating\n```\n\n\n# Documentation\n\nThere is templating in order to avoid using large text. Module `telegrinder_templating` has an `ABCTemplating` interface for creating templating classes.\n\n```python\nfrom telegrinder_templating import ABCTemplating\n```\n\n`telegrinder_templating` has class `JinjaTemplating` to work with jinja templates.\n\n```python\nfrom telegrinder_templating import JinjaTemplating\n```\n\n`JinjaTemplating` methods:\n* `render(template_name: str, **data: Any) -> str`\n* `render_from_string(template_source: str, **data: Any) -> str`\n* `@add_filter(key: str | None) -> wrapper(func: JinjaFilter)`\n\n\nExample:\n```python\nimport asyncio\nimport pathlib\n\nimport jinja2\n\nfrom telegrinder_templating import JinjaTemplating\n\njt = JinjaTemplating(pathlib.Path(__file__).resolve().parent / \"templates\")\n\n\n@jt.add_filter(\"title\")\ndef title_string(value: str, must_strip: bool = False) -> str:\n    if must_strip:\n        return value.strip().title()\n    return value.title()\n\n\nasync def main():\n    await jt.render(\"template.j2\", digits=[1, 2, 3])\n    await jt.render_from_string(\"{{ name|title(must_strip=True) }}\", name=\"  alex\")\n\n\nasyncio.run(main())\n```\n\nMore details about `Jinja` can be found [*HERE*](https://jinja.palletsprojects.com/en)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This module is intended for the Telegrinder framework. It allows for text templating.",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/luwqz1/telegrinder_templating",
        "Repository": "https://github.com/luwqz1/telegrinder_templating"
    },
    "split_keywords": [
        "python",
        "telegrinder framework",
        "tool",
        "templating",
        "telegrinder tool",
        "jinja2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d27b7203e9edfeb829fef95683af0e56f1357e0fc1511b8625391cdcecdf56c",
                "md5": "f865767d9f2278f4a2838c0d3feb4519",
                "sha256": "fd39e8bbf6b2f8d1884786dc23207cc3b59a09518a62049f1db7f9717357158e"
            },
            "downloads": -1,
            "filename": "telegrinder_templating-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f865767d9f2278f4a2838c0d3feb4519",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 3960,
            "upload_time": "2023-08-30T17:55:30",
            "upload_time_iso_8601": "2023-08-30T17:55:30.149383Z",
            "url": "https://files.pythonhosted.org/packages/4d/27/b7203e9edfeb829fef95683af0e56f1357e0fc1511b8625391cdcecdf56c/telegrinder_templating-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "898649641030eb3bf83523a32850d03ea2577a6d7b62f86130e2ebe8104c61f0",
                "md5": "8305483b0fe84b1b18b9d3c9bddd32f2",
                "sha256": "b6d35fa0a495adab1912705c4dc5945c7d68e04395168766f962ae80456ab9e8"
            },
            "downloads": -1,
            "filename": "telegrinder_templating-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "8305483b0fe84b1b18b9d3c9bddd32f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 3096,
            "upload_time": "2023-08-30T17:55:31",
            "upload_time_iso_8601": "2023-08-30T17:55:31.755605Z",
            "url": "https://files.pythonhosted.org/packages/89/86/49641030eb3bf83523a32850d03ea2577a6d7b62f86130e2ebe8104c61f0/telegrinder_templating-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-30 17:55:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "luwqz1",
    "github_project": "telegrinder_templating",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "telegrinder-templating"
}
        
Elapsed time: 0.10879s