tstring-html-bindings 0.1.0__tar.gz

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.
@@ -0,0 +1,355 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
10
+
11
+ [[package]]
12
+ name = "equivalent"
13
+ version = "1.0.2"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
16
+
17
+ [[package]]
18
+ name = "hashbrown"
19
+ version = "0.16.1"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
22
+
23
+ [[package]]
24
+ name = "heck"
25
+ version = "0.5.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
28
+
29
+ [[package]]
30
+ name = "indexmap"
31
+ version = "2.13.0"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
34
+ dependencies = [
35
+ "equivalent",
36
+ "hashbrown",
37
+ ]
38
+
39
+ [[package]]
40
+ name = "indoc"
41
+ version = "2.0.7"
42
+ source = "registry+https://github.com/rust-lang/crates.io-index"
43
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
44
+ dependencies = [
45
+ "rustversion",
46
+ ]
47
+
48
+ [[package]]
49
+ name = "libc"
50
+ version = "0.2.183"
51
+ source = "registry+https://github.com/rust-lang/crates.io-index"
52
+ checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
53
+
54
+ [[package]]
55
+ name = "memchr"
56
+ version = "2.8.0"
57
+ source = "registry+https://github.com/rust-lang/crates.io-index"
58
+ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
59
+
60
+ [[package]]
61
+ name = "memoffset"
62
+ version = "0.9.1"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
65
+ dependencies = [
66
+ "autocfg",
67
+ ]
68
+
69
+ [[package]]
70
+ name = "num-bigint"
71
+ version = "0.4.6"
72
+ source = "registry+https://github.com/rust-lang/crates.io-index"
73
+ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
74
+ dependencies = [
75
+ "num-integer",
76
+ "num-traits",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "num-integer"
81
+ version = "0.1.46"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
84
+ dependencies = [
85
+ "num-traits",
86
+ ]
87
+
88
+ [[package]]
89
+ name = "num-traits"
90
+ version = "0.2.19"
91
+ source = "registry+https://github.com/rust-lang/crates.io-index"
92
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
93
+ dependencies = [
94
+ "autocfg",
95
+ ]
96
+
97
+ [[package]]
98
+ name = "once_cell"
99
+ version = "1.21.4"
100
+ source = "registry+https://github.com/rust-lang/crates.io-index"
101
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
102
+
103
+ [[package]]
104
+ name = "portable-atomic"
105
+ version = "1.13.1"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
108
+
109
+ [[package]]
110
+ name = "proc-macro2"
111
+ version = "1.0.106"
112
+ source = "registry+https://github.com/rust-lang/crates.io-index"
113
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
114
+ dependencies = [
115
+ "unicode-ident",
116
+ ]
117
+
118
+ [[package]]
119
+ name = "pyo3"
120
+ version = "0.27.2"
121
+ source = "registry+https://github.com/rust-lang/crates.io-index"
122
+ checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d"
123
+ dependencies = [
124
+ "indoc",
125
+ "libc",
126
+ "memoffset",
127
+ "once_cell",
128
+ "portable-atomic",
129
+ "pyo3-build-config",
130
+ "pyo3-ffi",
131
+ "pyo3-macros",
132
+ "unindent",
133
+ ]
134
+
135
+ [[package]]
136
+ name = "pyo3-build-config"
137
+ version = "0.27.2"
138
+ source = "registry+https://github.com/rust-lang/crates.io-index"
139
+ checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
140
+ dependencies = [
141
+ "target-lexicon",
142
+ ]
143
+
144
+ [[package]]
145
+ name = "pyo3-ffi"
146
+ version = "0.27.2"
147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
148
+ checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089"
149
+ dependencies = [
150
+ "libc",
151
+ "pyo3-build-config",
152
+ ]
153
+
154
+ [[package]]
155
+ name = "pyo3-macros"
156
+ version = "0.27.2"
157
+ source = "registry+https://github.com/rust-lang/crates.io-index"
158
+ checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02"
159
+ dependencies = [
160
+ "proc-macro2",
161
+ "pyo3-macros-backend",
162
+ "quote",
163
+ "syn",
164
+ ]
165
+
166
+ [[package]]
167
+ name = "pyo3-macros-backend"
168
+ version = "0.27.2"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9"
171
+ dependencies = [
172
+ "heck",
173
+ "proc-macro2",
174
+ "pyo3-build-config",
175
+ "quote",
176
+ "syn",
177
+ ]
178
+
179
+ [[package]]
180
+ name = "quote"
181
+ version = "1.0.45"
182
+ source = "registry+https://github.com/rust-lang/crates.io-index"
183
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
184
+ dependencies = [
185
+ "proc-macro2",
186
+ ]
187
+
188
+ [[package]]
189
+ name = "rustversion"
190
+ version = "1.0.22"
191
+ source = "registry+https://github.com/rust-lang/crates.io-index"
192
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
193
+
194
+ [[package]]
195
+ name = "serde"
196
+ version = "1.0.228"
197
+ source = "registry+https://github.com/rust-lang/crates.io-index"
198
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
199
+ dependencies = [
200
+ "serde_core",
201
+ "serde_derive",
202
+ ]
203
+
204
+ [[package]]
205
+ name = "serde_core"
206
+ version = "1.0.228"
207
+ source = "registry+https://github.com/rust-lang/crates.io-index"
208
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
209
+ dependencies = [
210
+ "serde_derive",
211
+ ]
212
+
213
+ [[package]]
214
+ name = "serde_derive"
215
+ version = "1.0.228"
216
+ source = "registry+https://github.com/rust-lang/crates.io-index"
217
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
218
+ dependencies = [
219
+ "proc-macro2",
220
+ "quote",
221
+ "syn",
222
+ ]
223
+
224
+ [[package]]
225
+ name = "serde_spanned"
226
+ version = "0.6.9"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
229
+ dependencies = [
230
+ "serde",
231
+ ]
232
+
233
+ [[package]]
234
+ name = "syn"
235
+ version = "2.0.117"
236
+ source = "registry+https://github.com/rust-lang/crates.io-index"
237
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
238
+ dependencies = [
239
+ "proc-macro2",
240
+ "quote",
241
+ "unicode-ident",
242
+ ]
243
+
244
+ [[package]]
245
+ name = "target-lexicon"
246
+ version = "0.13.5"
247
+ source = "registry+https://github.com/rust-lang/crates.io-index"
248
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
249
+
250
+ [[package]]
251
+ name = "toml"
252
+ version = "0.8.23"
253
+ source = "registry+https://github.com/rust-lang/crates.io-index"
254
+ checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
255
+ dependencies = [
256
+ "serde",
257
+ "serde_spanned",
258
+ "toml_datetime",
259
+ "toml_edit",
260
+ ]
261
+
262
+ [[package]]
263
+ name = "toml_datetime"
264
+ version = "0.6.11"
265
+ source = "registry+https://github.com/rust-lang/crates.io-index"
266
+ checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
267
+ dependencies = [
268
+ "serde",
269
+ ]
270
+
271
+ [[package]]
272
+ name = "toml_edit"
273
+ version = "0.22.27"
274
+ source = "registry+https://github.com/rust-lang/crates.io-index"
275
+ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
276
+ dependencies = [
277
+ "indexmap",
278
+ "serde",
279
+ "serde_spanned",
280
+ "toml_datetime",
281
+ "toml_write",
282
+ "winnow",
283
+ ]
284
+
285
+ [[package]]
286
+ name = "toml_write"
287
+ version = "0.1.2"
288
+ source = "registry+https://github.com/rust-lang/crates.io-index"
289
+ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
290
+
291
+ [[package]]
292
+ name = "tstring-html"
293
+ version = "0.1.0"
294
+ dependencies = [
295
+ "tstring-syntax",
296
+ ]
297
+
298
+ [[package]]
299
+ name = "tstring-html-backend-e2e-tests"
300
+ version = "0.1.0"
301
+ dependencies = [
302
+ "serde",
303
+ "toml",
304
+ "tstring-html",
305
+ "tstring-syntax",
306
+ "tstring-thtml",
307
+ ]
308
+
309
+ [[package]]
310
+ name = "tstring-html-bindings"
311
+ version = "0.1.0"
312
+ dependencies = [
313
+ "pyo3",
314
+ "tstring-html",
315
+ "tstring-syntax",
316
+ "tstring-thtml",
317
+ ]
318
+
319
+ [[package]]
320
+ name = "tstring-syntax"
321
+ version = "0.2.1"
322
+ source = "registry+https://github.com/rust-lang/crates.io-index"
323
+ checksum = "9ad566997891426a640b07af2330b9c08ad04e918f905880885d78a21304d9ee"
324
+ dependencies = [
325
+ "num-bigint",
326
+ ]
327
+
328
+ [[package]]
329
+ name = "tstring-thtml"
330
+ version = "0.1.0"
331
+ dependencies = [
332
+ "tstring-html",
333
+ "tstring-syntax",
334
+ ]
335
+
336
+ [[package]]
337
+ name = "unicode-ident"
338
+ version = "1.0.24"
339
+ source = "registry+https://github.com/rust-lang/crates.io-index"
340
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
341
+
342
+ [[package]]
343
+ name = "unindent"
344
+ version = "0.2.4"
345
+ source = "registry+https://github.com/rust-lang/crates.io-index"
346
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
347
+
348
+ [[package]]
349
+ name = "winnow"
350
+ version = "0.7.15"
351
+ source = "registry+https://github.com/rust-lang/crates.io-index"
352
+ checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
353
+ dependencies = [
354
+ "memchr",
355
+ ]
@@ -0,0 +1,16 @@
1
+ [workspace]
2
+ members = ["tstring-html-bindings", "tstring-html-rs", "tstring-thtml-rs"]
3
+ resolver = "2"
4
+
5
+ [workspace.package]
6
+ authors = ["Koudai Aono <koxudaxi@gmail.com>"]
7
+ edition = "2024"
8
+ homepage = "https://github.com/koxudaxi/tstring-html"
9
+ license = "MIT"
10
+ repository = "https://github.com/koxudaxi/tstring-html"
11
+ rust-version = "1.94.0"
12
+ version = "0.1.0"
13
+
14
+ [workspace.dependencies]
15
+ pyo3 = "0.27.1"
16
+ tstring-syntax = { version = "=0.2.1" }
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: tstring-html-bindings
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.14
10
+ Classifier: Programming Language :: Rust
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Summary: Native Python bindings for tstring-html
13
+ Keywords: html,pep750,t-strings,template-strings,thtml
14
+ Home-Page: https://github.com/koxudaxi/tstring-html
15
+ Author-email: Koudai Aono <koxudaxi@gmail.com>
16
+ Maintainer-email: Koudai Aono <koxudaxi@gmail.com>
17
+ License: MIT
18
+ Requires-Python: >=3.14
19
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
20
+ Project-URL: Changelog, https://github.com/koxudaxi/tstring-html/blob/main/CHANGELOG.md
21
+ Project-URL: Documentation, https://github.com/koxudaxi/tstring-html/blob/main/rust/tstring-html-bindings/README.md
22
+ Project-URL: Homepage, https://github.com/koxudaxi/tstring-html
23
+ Project-URL: Issues, https://github.com/koxudaxi/tstring-html/issues
24
+ Project-URL: Repository, https://github.com/koxudaxi/tstring-html
25
+
26
+ # tstring-html-bindings
27
+
28
+ Shared native bindings for `html-tstring` and `thtml-tstring`.
29
+
@@ -0,0 +1,3 @@
1
+ # tstring-html-bindings
2
+
3
+ Shared native bindings for `html-tstring` and `thtml-tstring`.
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "tstring-html-bindings"
3
+ version = "0.1.0"
4
+ description = "Native Python bindings for tstring-html"
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ authors = [{ name = "Koudai Aono", email = "koxudaxi@gmail.com" }]
8
+ maintainers = [{ name = "Koudai Aono", email = "koxudaxi@gmail.com" }]
9
+ requires-python = ">=3.14"
10
+ keywords = ["html", "pep750", "t-strings", "template-strings", "thtml"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Programming Language :: Python :: 3.14",
18
+ "Programming Language :: Rust",
19
+ "Topic :: Software Development :: Libraries :: Python Modules",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/koxudaxi/tstring-html"
24
+ Repository = "https://github.com/koxudaxi/tstring-html"
25
+ Documentation = "https://github.com/koxudaxi/tstring-html/blob/main/rust/tstring-html-bindings/README.md"
26
+ Changelog = "https://github.com/koxudaxi/tstring-html/blob/main/CHANGELOG.md"
27
+ Issues = "https://github.com/koxudaxi/tstring-html/issues"
28
+
29
+ [build-system]
30
+ requires = ["maturin>=1.8,<2.0"]
31
+ build-backend = "maturin"
32
+
33
+ [tool.maturin]
34
+ bindings = "pyo3"
35
+ features = ["extension-module"]
36
+ module-name = "tstring_html_bindings.tstring_html_bindings"
37
+ manifest-path = "tstring-html-bindings/Cargo.toml"
38
+ python-source = "python"
@@ -0,0 +1,86 @@
1
+ from __future__ import annotations
2
+
3
+ from string.templatelib import Template
4
+ from typing import Literal
5
+
6
+ from .tstring_html_bindings import (
7
+ CompiledHtmlTemplate,
8
+ CompiledThtmlTemplate,
9
+ Fragment,
10
+ RawHtml,
11
+ TemplateError,
12
+ TemplateParseError,
13
+ TemplateRuntimeError,
14
+ TemplateSemanticError,
15
+ check_html_template,
16
+ check_thtml_template,
17
+ compile_html_template,
18
+ compile_thtml_template,
19
+ format_html_template,
20
+ format_thtml_template,
21
+ render_html_fragment,
22
+ render_html_template,
23
+ render_thtml_template,
24
+ )
25
+
26
+
27
+ class Renderable:
28
+ __slots__ = ("backend", "template", "_globals", "_locals")
29
+
30
+ __tstring_renderable__ = True
31
+
32
+ def __init__(
33
+ self,
34
+ backend: Literal["html", "thtml"],
35
+ template: Template,
36
+ *,
37
+ globals: dict[str, object] | None = None,
38
+ locals: dict[str, object] | None = None,
39
+ ) -> None:
40
+ if backend not in {"html", "thtml"}:
41
+ raise ValueError("Renderable backend must be 'html' or 'thtml'.")
42
+ self.backend = backend
43
+ self.template = template
44
+ self._globals = globals
45
+ self._locals = locals
46
+
47
+ def render(self) -> str:
48
+ if self.backend == "html":
49
+ return render_html_template(self.template)
50
+ if self._globals is None or self._locals is None:
51
+ raise TemplateRuntimeError(
52
+ "T-HTML Renderable is missing captured globals/locals."
53
+ )
54
+ return render_thtml_template(
55
+ self.template, globals=self._globals, locals=self._locals
56
+ )
57
+
58
+ def render_fragment(self) -> str:
59
+ if self.backend == "html":
60
+ return render_html_fragment(self.template)
61
+ return self.render()
62
+
63
+ def __repr__(self) -> str:
64
+ return f"Renderable(backend={self.backend!r})"
65
+
66
+
67
+ __all__ = [
68
+ "CompiledHtmlTemplate",
69
+ "CompiledThtmlTemplate",
70
+ "Fragment",
71
+ "RawHtml",
72
+ "Renderable",
73
+ "TemplateError",
74
+ "TemplateParseError",
75
+ "TemplateRuntimeError",
76
+ "TemplateSemanticError",
77
+ "check_html_template",
78
+ "check_thtml_template",
79
+ "compile_html_template",
80
+ "compile_thtml_template",
81
+ "format_html_template",
82
+ "format_thtml_template",
83
+ "render_html_fragment",
84
+ "render_html_template",
85
+ "render_thtml_template",
86
+ ]
@@ -0,0 +1,27 @@
1
+ [package]
2
+ name = "tstring-html-bindings"
3
+ description = "Native Python bindings for tstring-html"
4
+ edition.workspace = true
5
+ homepage.workspace = true
6
+ license.workspace = true
7
+ repository.workspace = true
8
+ rust-version.workspace = true
9
+ version.workspace = true
10
+ readme = "README.md"
11
+
12
+ [lib]
13
+ name = "tstring_html_bindings"
14
+ crate-type = ["cdylib"]
15
+
16
+ [features]
17
+ default = []
18
+ extension-module = ["pyo3/extension-module"]
19
+
20
+ [dependencies]
21
+ pyo3 = { workspace = true, features = ["abi3-py314"] }
22
+ tstring-html = { version = "0.1.0", path = "../tstring-html-rs" }
23
+ tstring-thtml = { version = "0.1.0", path = "../tstring-thtml-rs" }
24
+ tstring-syntax.workspace = true
25
+
26
+ [dev-dependencies]
27
+ pyo3 = { workspace = true, features = ["auto-initialize"] }
@@ -0,0 +1,3 @@
1
+ # tstring-html-bindings
2
+
3
+ Shared native bindings for `html-tstring` and `thtml-tstring`.