https://github.com/hoishing/kTemplate
a minimalist python html template
https://github.com/hoishing/kTemplate
python template
Last synced: 4 months ago
JSON representation
a minimalist python html template
- Host: GitHub
- URL: https://github.com/hoishing/kTemplate
- Owner: hoishing
- License: mit
- Created: 2023-01-07T03:19:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T01:44:04.000Z (about 2 years ago)
- Last Synced: 2024-03-15T01:03:44.417Z (about 1 year ago)
- Topics: python, template
- Language: Python
- Homepage: https://hoishing.github.io/kTemplate
- Size: 725 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - hoishing/kTemplate - a minimalist python html template (Python)
README
# kTemplate
[![ci-badge]][ci-url] [![pypi-badge]][pypi-url] [![MIT-badge]][MIT-url] [![black-badge]][black-url]
> a minimalist python html template
- [docs]
## Quick Start
### Installation
`pip install kTemplate`
### Examples
```python
from kTemplate import (
div, img, # common html elements
element # for creating custom element
)# create common html element
# `class` represents by `cls` due to python keyword
html_str = div(img(src='url'), cls='bar')
## create custom element
my_element = element(tag="MyElement", content="foo" props="bar")
# foo
```see also: how to create [templates and components]
## Motivation
When creating simple website, instead of seperating python and template files like this:
```html
- {{ item.caption }}
{% for item in navigation %}
{% endfor %}
```
I prefer a pure python approach like this:
```python
ul(
id = "navigation",
content = [
li(
a(item.caption, href=item.href)
)
for item in navigation
]
)
```
It provides full intellisense, type checking, and all language supports from the text editor. I feel a better DX with this approach.
## Need Help?
Open a [github issue] or ping me on [Twitter ![twitter-icon]][Twitter]
[github issue]: https://github.com/hoishing/kTemplate/issues
[Twitter]: https://twitter.com/hoishing
[twitter-icon]: https://api.iconify.design/logos/twitter.svg?width=20
[ci-badge]: https://github.com/hoishing/kTemplate/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/hoishing/kTemplate/actions/workflows/ci.yml
[MIT-badge]: https://img.shields.io/github/license/hoishing/kTemplate
[MIT-url]: https://opensource.org/licenses/MIT
[pypi-badge]: https://img.shields.io/pypi/v/ktemplate
[pypi-url]: https://pypi.org/project/ktemplate/
[black-badge]: https://img.shields.io/badge/code%20style-black-000000.svg
[black-url]: https://github.com/psf/black
[templates and components]: https://hoishing.github.io/kTemplate/usage/#templates-and-components
[docs]: https://hoishing.github.io/kTemplate