xcomponent 0.10.2__tar.gz → 0.10.4__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.
- {xcomponent-0.10.2 → xcomponent-0.10.4}/CHANGELOG.md +10 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/Cargo.lock +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/Cargo.toml +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/PKG-INFO +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/pyproject.toml +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/ast/eval.rs +13 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/markup/tokens.rs +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_binary_op.py +36 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_import_namespace.py +68 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/uv.lock +1 -1
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/build-sdist.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/build-wheels.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/publish-doc.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/publish-pypi.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/release.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/tests-artifacts.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.github/workflows/tests.yml +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.gitignore +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/.python-version +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/Justfile +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/LICENSE +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/README.md +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/Makefile +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/source/conf.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/source/develop/.gitkeep +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/source/index.md +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/source/user/changelog.md +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/docs/source/user/getting_started.md +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/scripts/get_version.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/scripts/write_changelog.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/adapters/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/adapters/babel.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/py.typed +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/service/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/service/catalog.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/python/xcomponent/xcore.pyi +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/catalog/catalog.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/catalog/mod.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/context.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/ast/mod.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/ast/model.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/ast/parse.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/grammar.pest +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/i18n.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/mod.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/parser.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/expression/tokens.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/lib.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/markup/grammar.pest +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/markup/mod.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/src/rust/markup/parser.rs +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/babel.ini +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/fr.mo +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/fr.po +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/mydomain.pot +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/functionals/i18n/test_l10n.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/adapters/__init__.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/adapters/test_babel.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/conftest.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_binary_eq.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_binary_op_bool.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_default_values.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_field_access.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_for_expr.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_func.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_if_expr.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_let.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_nested.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_render_comment.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_script.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_str_dedent.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_str_method.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_types.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/expression/test_unary.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_core.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_named_component.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_attributes.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_context.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_globals.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_globals_obj.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_globals_obj2.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_nested_dict.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_nested_node.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_node.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_properties.py +0 -0
- {xcomponent-0.10.2 → xcomponent-0.10.4}/tests/unittests/test_render_script.py +0 -0
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.10.4 - 2025-12-22
|
|
2
|
+
|
|
3
|
+
* Fix lazy evuation of binary operator (and and or).
|
|
4
|
+
before this version, right arm branch was also evaluated leading to bugs,
|
|
5
|
+
and requires to add nested if statement to avoid them.
|
|
6
|
+
|
|
7
|
+
## 0.10.3 - 2025-12-21
|
|
8
|
+
|
|
9
|
+
* Do not alter default templates parameter values.
|
|
10
|
+
|
|
1
11
|
## 0.10.2 - 2025-12-21
|
|
2
12
|
|
|
3
13
|
* Fix i18n extraction for namescape components.
|
|
@@ -211,6 +211,19 @@ pub fn eval_ast<'py>(
|
|
|
211
211
|
|
|
212
212
|
AST::Binary { left, op, right } => {
|
|
213
213
|
let l = eval_ast(py, left, catalog, context)?;
|
|
214
|
+
match op {
|
|
215
|
+
Operator::And => {
|
|
216
|
+
if !l.is_truthy() {
|
|
217
|
+
return Ok(l);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
Operator::Or => {
|
|
221
|
+
if l.is_truthy() {
|
|
222
|
+
return Ok(l);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
_ => (),
|
|
226
|
+
}
|
|
214
227
|
let r = eval_ast(py, right, catalog, context)?;
|
|
215
228
|
|
|
216
229
|
match op {
|
|
@@ -361,7 +361,7 @@ impl ToHtml for XNSElement {
|
|
|
361
361
|
let pynamespaces: &Bound<'_, PyDict> = namespaces.bind(py).downcast().unwrap();
|
|
362
362
|
|
|
363
363
|
let defaults = template.getattr(py, "defaults")?;
|
|
364
|
-
let node_attrs
|
|
364
|
+
let node_attrs = defaults.bind(py).downcast().unwrap().copy().unwrap();
|
|
365
365
|
|
|
366
366
|
context.push_ns(py, pynamespaces.clone())?;
|
|
367
367
|
for (name, attrnode) in self.attrs() {
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
1
2
|
from typing import Any, Literal
|
|
2
|
-
import pytest
|
|
3
3
|
|
|
4
|
+
import pytest
|
|
4
5
|
from xcomponent import Catalog, XNode
|
|
5
6
|
from xcomponent.service.catalog import Component
|
|
6
7
|
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Person:
|
|
11
|
+
name: str
|
|
12
|
+
|
|
13
|
+
|
|
7
14
|
catalog = Catalog()
|
|
8
15
|
|
|
9
16
|
|
|
@@ -12,6 +19,20 @@ def AddOp(a: int | bool | str, b: int | bool | str) -> str:
|
|
|
12
19
|
return """<>{a + b}</>"""
|
|
13
20
|
|
|
14
21
|
|
|
22
|
+
@catalog.component
|
|
23
|
+
def HelloWorld(person: Person | None) -> str:
|
|
24
|
+
return """
|
|
25
|
+
<>Hello { if person and person.name {<>{person.name}</>} else {<>World</>} }!</>
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@catalog.component
|
|
30
|
+
def LazyOr(person: Person | None, person2: Person | None) -> str:
|
|
31
|
+
return """
|
|
32
|
+
<>Hello { person and person.name or person2.name }!</>
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
|
|
15
36
|
@catalog.component
|
|
16
37
|
def Button(
|
|
17
38
|
children: XNode,
|
|
@@ -233,3 +254,17 @@ def test_precendence_op(component: str, expected: str):
|
|
|
233
254
|
)
|
|
234
255
|
def test_priority_op(component: str, expected: str):
|
|
235
256
|
assert component == expected
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@pytest.mark.parametrize(
|
|
260
|
+
"component,expected",
|
|
261
|
+
[
|
|
262
|
+
pytest.param(HelloWorld(None), "Hello World!"),
|
|
263
|
+
pytest.param(HelloWorld(Person(name="")), "Hello World!"),
|
|
264
|
+
pytest.param(HelloWorld(Person(name="Bob")), "Hello Bob!"),
|
|
265
|
+
pytest.param(LazyOr(Person(name="Alice"), None), "Hello Alice!"),
|
|
266
|
+
pytest.param(LazyOr(None, Person(name="Bob")), "Hello Bob!"),
|
|
267
|
+
],
|
|
268
|
+
)
|
|
269
|
+
def test_lazy_evaluation(component: str, expected: str):
|
|
270
|
+
assert component == expected
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
1
4
|
import pytest
|
|
2
5
|
from xcomponent import Catalog, XNode
|
|
3
6
|
|
|
4
7
|
|
|
8
|
+
@dataclass
|
|
9
|
+
class App:
|
|
10
|
+
name: str
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
@pytest.fixture
|
|
6
14
|
def base_catalog():
|
|
7
15
|
base = Catalog()
|
|
@@ -96,6 +104,40 @@ def page_catalog(
|
|
|
96
104
|
</layout.Layout>
|
|
97
105
|
"""
|
|
98
106
|
|
|
107
|
+
@page.component(use={"layout": layout_catalog, "app": app_catalog})
|
|
108
|
+
def Page5(children: XNode, title: str, apps: list[App]) -> str:
|
|
109
|
+
return """
|
|
110
|
+
<layout.Layout
|
|
111
|
+
title={title}
|
|
112
|
+
side_bar={<app.Sidebar/>}
|
|
113
|
+
>
|
|
114
|
+
{
|
|
115
|
+
for app in globals.apps {
|
|
116
|
+
<p>{app.name}</p>
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</layout.Layout>
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
@page.component
|
|
123
|
+
def P(children: XNode) -> str:
|
|
124
|
+
return "<p>{children}</p>"
|
|
125
|
+
|
|
126
|
+
@page.component(use={"layout": layout_catalog, "app": app_catalog})
|
|
127
|
+
def Page6(children: XNode, title: str, apps: list[App]) -> str:
|
|
128
|
+
return """
|
|
129
|
+
<layout.Layout
|
|
130
|
+
title={title}
|
|
131
|
+
side_bar={<app.Sidebar/>}
|
|
132
|
+
>
|
|
133
|
+
{
|
|
134
|
+
for app in globals.apps {
|
|
135
|
+
<P>{app.name}</P>
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</layout.Layout>
|
|
139
|
+
"""
|
|
140
|
+
|
|
99
141
|
return page
|
|
100
142
|
|
|
101
143
|
|
|
@@ -131,3 +173,29 @@ def page_catalog(
|
|
|
131
173
|
def test_namespace(page_catalog: Catalog, doc: str, expected: str):
|
|
132
174
|
page = page_catalog.render(doc)
|
|
133
175
|
assert page == expected
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@pytest.mark.parametrize(
|
|
179
|
+
"doc,params,expected",
|
|
180
|
+
[
|
|
181
|
+
pytest.param(
|
|
182
|
+
"<Page5 title='yolo'/>",
|
|
183
|
+
{"globals": {"apps": [App(name="foo"), App(name="bar")]}},
|
|
184
|
+
'<html><head><title>yolo</title></head><body><h1 class="xl">yolo</h1>'
|
|
185
|
+
'<div><aside><menu><li><a href="#">Parameters</a></li></menu></aside>'
|
|
186
|
+
"<div><p>foo</p><p>bar</p></div></div></body></html>",
|
|
187
|
+
id="override-local-name",
|
|
188
|
+
),
|
|
189
|
+
pytest.param(
|
|
190
|
+
"<Page6 title='yolo'/>",
|
|
191
|
+
{"globals": {"apps": [App(name="foo"), App(name="bar")]}},
|
|
192
|
+
'<html><head><title>yolo</title></head><body><h1 class="xl">yolo</h1>'
|
|
193
|
+
'<div><aside><menu><li><a href="#">Parameters</a></li></menu></aside>'
|
|
194
|
+
"<div><p>foo</p><p>bar</p></div></div></body></html>",
|
|
195
|
+
id="override-local-name-with-component",
|
|
196
|
+
),
|
|
197
|
+
],
|
|
198
|
+
)
|
|
199
|
+
def test_namespace_params(page_catalog: Catalog, doc: str, params: Any, expected: str):
|
|
200
|
+
page = page_catalog.render(doc, **params)
|
|
201
|
+
assert page == expected
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|