python-fragments 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fragments/__init__.py +0 -0
- fragments/ast_nodes.py +237 -0
- fragments/cli.py +20 -0
- fragments/grammar.py +206 -0
- fragments/html/__init__.py +0 -0
- fragments/html/elements.py +54 -0
- fragments/loader.py +32 -0
- fragments/lsp/__init__.py +0 -0
- fragments/lsp/completion.py +79 -0
- fragments/lsp/definition.py +49 -0
- fragments/lsp/file_state.py +109 -0
- fragments/lsp/hover.py +44 -0
- fragments/lsp/lifecycle.py +116 -0
- fragments/lsp/pyright.py +94 -0
- fragments/lsp/rename.py +106 -0
- fragments/lsp/semantic_tokens.py +42 -0
- fragments/lsp/server.py +129 -0
- fragments/source.py +26 -0
- fragments/transpiler.py +10 -0
- python_fragments-0.1.dist-info/METADATA +55 -0
- python_fragments-0.1.dist-info/RECORD +24 -0
- python_fragments-0.1.dist-info/WHEEL +5 -0
- python_fragments-0.1.dist-info/entry_points.txt +3 -0
- python_fragments-0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-fragments
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: HTML template rendering in Python
|
|
5
|
+
Author-email: The Running Algorithm <services@therunningalgorithm.info>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Provides-Extra: lsp
|
|
10
|
+
Requires-Dist: basedpyright>=1.39.0; extra == "lsp"
|
|
11
|
+
Requires-Dist: pygls>=1.3.0; extra == "lsp"
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8.4.1; extra == "dev"
|
|
14
|
+
|
|
15
|
+
# Python Fragments
|
|
16
|
+
|
|
17
|
+
> **This package is in early development and not yet stable. The API may change without notice between releases.**
|
|
18
|
+
|
|
19
|
+
Production-ready, modern HTML template rendering in Python — no build step, no template files, and native HTML awareness out of the box.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from fragments import loader # isort: skip
|
|
23
|
+
|
|
24
|
+
from fastapi import FastAPI
|
|
25
|
+
from fastapi.responses import HTMLResponse
|
|
26
|
+
from components import Layout, PostCard
|
|
27
|
+
|
|
28
|
+
app = FastAPI()
|
|
29
|
+
|
|
30
|
+
POSTS = [...]
|
|
31
|
+
|
|
32
|
+
@app.get("/", response_class=HTMLResponse)
|
|
33
|
+
async def index() -> str:
|
|
34
|
+
published = [p for p in POSTS if p.published]
|
|
35
|
+
return <>
|
|
36
|
+
<Layout title="My Blog">
|
|
37
|
+
<h1>Latest Posts</h1>
|
|
38
|
+
<PostCard for={{ post in published }} post={{ post }} />
|
|
39
|
+
</Layout>
|
|
40
|
+
</>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install python-fragments
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Register the loader at your application's entry point, before importing any modules that contain fragments:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from fragments import loader # isort: skip
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Any `.py` file containing `<>` is transpiled automatically. Nothing else to configure.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
fragments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
fragments/ast_nodes.py,sha256=BC78kYrEP-Le8dRqgPYcojbC5nmQL1_pS1P4N3yumWk,9016
|
|
3
|
+
fragments/cli.py,sha256=JtoG3qWyMB_fB95jsT9CdHNrcY_1Pge6B5i1KYkIP5s,462
|
|
4
|
+
fragments/grammar.py,sha256=ZHQwboYGGo_CEWhERY2Od_ljlMNxJ46pgv7nWsGKddo,8415
|
|
5
|
+
fragments/loader.py,sha256=7nlsXVjCpRRmd939UJQqd9NWbE2-3ZtbO0aFfz3zCs8,980
|
|
6
|
+
fragments/source.py,sha256=Q87doQNejqJB03YfwZWyTp6c8hA4gfKNRo4q0MZ-htI,783
|
|
7
|
+
fragments/transpiler.py,sha256=O4pusCuv_Hbms2J0AP3tun-uNkXfb27RBUugr_0dIVA,316
|
|
8
|
+
fragments/html/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
fragments/html/elements.py,sha256=HRKZerlLu2yzo80njjSRs0JjfE9npNzZiXf3uteOF_I,1486
|
|
10
|
+
fragments/lsp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
fragments/lsp/completion.py,sha256=BdEu36WN-IwyxbzrvcfLOJ-YiCQn0tzbsIaGUJJuSsk,3260
|
|
12
|
+
fragments/lsp/definition.py,sha256=eXTziJn-lHUERCTwdHTNWFXyoKfmAZGmmBlqEsxuGiQ,1905
|
|
13
|
+
fragments/lsp/file_state.py,sha256=A5yt63PdfaPy-4RHkC7zHkW8BtzP937p9dNT22bDbeg,5896
|
|
14
|
+
fragments/lsp/hover.py,sha256=StCBfewkXvf_nBTBVr7pS1r0eQfdwJ1fCFWG50qO_Yc,1622
|
|
15
|
+
fragments/lsp/lifecycle.py,sha256=tRhGeT5NbJ4DYYhsjzWa9sRoPCougYmtAAspsP8iFK8,4622
|
|
16
|
+
fragments/lsp/pyright.py,sha256=nAxzvxKGqAj039ZZzopyd4MhaMSNjThO8Av-wQxGZM8,3652
|
|
17
|
+
fragments/lsp/rename.py,sha256=k6h4uHTnXpLatPgIkTY7oQDEd6p17NqVq1OLd8mtsEA,4305
|
|
18
|
+
fragments/lsp/semantic_tokens.py,sha256=BbfchVffOKG8jrjpddl69yuSWsXDwNClQrnZvcu53oI,1986
|
|
19
|
+
fragments/lsp/server.py,sha256=6YYdb9LBqkSOpaybjlm71LngiSDCO0QUYf9KXWpTffw,5217
|
|
20
|
+
python_fragments-0.1.dist-info/METADATA,sha256=iVWpraFHWqa9eHOwJ7GfSbBBvcEQsB7dxVLBn9ByaBE,1529
|
|
21
|
+
python_fragments-0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
22
|
+
python_fragments-0.1.dist-info/entry_points.txt,sha256=SJa8O1NUgYJyW_kDbJCz7bbwijlTCneTqwj9UCnFS-A,91
|
|
23
|
+
python_fragments-0.1.dist-info/top_level.txt,sha256=4r1SNnHOK3BVhAT_KgV8MRq9kiV23yK_rnuTAEl5oRg,10
|
|
24
|
+
python_fragments-0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fragments
|