sodom


Namesodom JSON
Version 1.4.0 PyPI version JSON
download
home_page
Summarysodom if you like to write HTML in Python.
upload_time2024-02-12 17:38:44
maintainer
docs_urlNone
author
requires_python>=3.12
licenseLGPL-3.0-or-newer
keywords framework templating template html python html5
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sodom
__sodom__ if you like to write HTML in Python. __Faster x2~ than `dominate`__
## Installation
```bash
python -m pip install sodom[cli]
```

## Examples
You can check demo via `python -m sodom` or preview code in `sodom.__main__`.
```python
from sodom import *
...
def card(_header: str, _price: str, _submit_text: str, *_conditions: str):
    with div(class_='card mb-4 box-shadow'):
        with div(class_='card-header'), h4(class_='my-0 font-weight-normal'):
            text(_header)
        with div(class_='card-body'):
            with h1(class_='card-title pricing-card-title'):
                text(_price)
                with small(class_='text-muted'):
                    text(' mo')
            with ul(class_='list-unstyled mt-3 mb-4'):
                for _c in _conditions:
                    li(_c)
            with button(type_='button', class_='btn btn-lg btn-block btn-primary'):
                text(_submit_text)
...
```

Also added special operations:
```python
Attrs(foo='bar').merge(foo='baz')
Attrs(foo='bar').merge(**Attrs(foo='baz'))
Attrs(foo='bar').merge(**dict(foo='baz'))
Attrs(foo='bar') | Attrs(foo='baz')
Attrs(foo='bar') | {'foo': 'baz'}
# return `Attrs(foo='bar baz'})`

with div() < Attrs(foo='bar') as doc: ...
with div() < {'foo': 'bar'} as doc: ...
# return `<div foo="bar"></div>`

with div() < Attrs(foo='bar') | {'foo': 'baz'} as doc: ...
# return `<div foo="bar baz"></div>`

```

## CLI Generation
Require `[cli]` extra.
```bash
python -m pip install sodom[cli]
```
Check out `--help`.
```bash
python -m sodom --help
```

## Features
- supported standart html element (normal/void). Check `sodom.literals.NORMAL_TAGS` and `sodom.literals.VOID_TAGS`.
- by default, all underscores(`_`) will be replaced by minus(`-`). Use `replace_underscores` in renderers to replace only _special_ attributes like `data-`, `v-`... Check `sodom.literals.SPECIAL_ATTRS`. You can extend list in runtime __before__ library usage.
- sodom is x2~ times faster than `dominate` and x4+ times than `fast_html`. Check `sodom.tests.test_performance_*`.
- avoided builtin keyword trouble via cutting off leading and ending `_` of element names. For example, `[py]class_='button'` equals `[html]class="button"`. Check `python -m sodom demo` or `sodom.__main__.demo`
- supported `ContextVar`. Tested on `asyncio` and `ThreadPoolExecutor`.
- supported python generation from `.html`.
- include simple integrations with `aiohttp`, `flask`, `sanic`, `quart`. Check `sodom.ext.`

## Feedback
If you have any feedback, text me at inbox@protaz.ru

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sodom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": "",
    "keywords": "framework,templating,template,html,python,html5",
    "author": "",
    "author_email": "Dmitry Protasov <inbox@protaz.ru>",
    "download_url": "https://files.pythonhosted.org/packages/69/da/da2de79e05a1be6276ca60d5d07b1001a0d8544eb6fb89a0a602a8d35fcb/sodom-1.4.0.tar.gz",
    "platform": null,
    "description": "# sodom\n__sodom__ if you like to write HTML in Python. __Faster x2~ than `dominate`__\n## Installation\n```bash\npython -m pip install sodom[cli]\n```\n\n## Examples\nYou can check demo via `python -m sodom` or preview code in `sodom.__main__`.\n```python\nfrom sodom import *\n...\ndef card(_header: str, _price: str, _submit_text: str, *_conditions: str):\n    with div(class_='card mb-4 box-shadow'):\n        with div(class_='card-header'), h4(class_='my-0 font-weight-normal'):\n            text(_header)\n        with div(class_='card-body'):\n            with h1(class_='card-title pricing-card-title'):\n                text(_price)\n                with small(class_='text-muted'):\n                    text(' mo')\n            with ul(class_='list-unstyled mt-3 mb-4'):\n                for _c in _conditions:\n                    li(_c)\n            with button(type_='button', class_='btn btn-lg btn-block btn-primary'):\n                text(_submit_text)\n...\n```\n\nAlso added special operations:\n```python\nAttrs(foo='bar').merge(foo='baz')\nAttrs(foo='bar').merge(**Attrs(foo='baz'))\nAttrs(foo='bar').merge(**dict(foo='baz'))\nAttrs(foo='bar') | Attrs(foo='baz')\nAttrs(foo='bar') | {'foo': 'baz'}\n# return `Attrs(foo='bar baz'})`\n\nwith div() < Attrs(foo='bar') as doc: ...\nwith div() < {'foo': 'bar'} as doc: ...\n# return `<div foo=\"bar\"></div>`\n\nwith div() < Attrs(foo='bar') | {'foo': 'baz'} as doc: ...\n# return `<div foo=\"bar baz\"></div>`\n\n```\n\n## CLI Generation\nRequire `[cli]` extra.\n```bash\npython -m pip install sodom[cli]\n```\nCheck out `--help`.\n```bash\npython -m sodom --help\n```\n\n## Features\n- supported standart html element (normal/void). Check `sodom.literals.NORMAL_TAGS` and `sodom.literals.VOID_TAGS`.\n- by default, all underscores(`_`) will be replaced by minus(`-`). Use `replace_underscores` in renderers to replace only _special_ attributes like `data-`, `v-`... Check `sodom.literals.SPECIAL_ATTRS`. You can extend list in runtime __before__ library usage.\n- sodom is x2~ times faster than `dominate` and x4+ times than `fast_html`. Check `sodom.tests.test_performance_*`.\n- avoided builtin keyword trouble via cutting off leading and ending `_` of element names. For example, `[py]class_='button'` equals `[html]class=\"button\"`. Check `python -m sodom demo` or `sodom.__main__.demo`\n- supported `ContextVar`. Tested on `asyncio` and `ThreadPoolExecutor`.\n- supported python generation from `.html`.\n- include simple integrations with `aiohttp`, `flask`, `sanic`, `quart`. Check `sodom.ext.`\n\n## Feedback\nIf you have any feedback, text me at inbox@protaz.ru\n",
    "bugtrack_url": null,
    "license": "LGPL-3.0-or-newer",
    "summary": "sodom if you like to write HTML in Python.",
    "version": "1.4.0",
    "project_urls": {
        "Homepage": "https://codeberg.org/protasov/sodom",
        "PyPi": "https://pypi.org/project/sodom/",
        "Source": "https://codeberg.org/protasov/sodom"
    },
    "split_keywords": [
        "framework",
        "templating",
        "template",
        "html",
        "python",
        "html5"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69dada2de79e05a1be6276ca60d5d07b1001a0d8544eb6fb89a0a602a8d35fcb",
                "md5": "16f222f019eb470c7850006de1f6812a",
                "sha256": "b3eb0e771c3665d5f002351e0e6cc423233721c3ee5215b35ecd66f6e1e030f5"
            },
            "downloads": -1,
            "filename": "sodom-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "16f222f019eb470c7850006de1f6812a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 18671,
            "upload_time": "2024-02-12T17:38:44",
            "upload_time_iso_8601": "2024-02-12T17:38:44.048197Z",
            "url": "https://files.pythonhosted.org/packages/69/da/da2de79e05a1be6276ca60d5d07b1001a0d8544eb6fb89a0a602a8d35fcb/sodom-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-12 17:38:44",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "protasov",
    "codeberg_project": "sodom",
    "lcname": "sodom"
}
        
Elapsed time: 0.18672s