xcomponent 0.6.1__tar.gz → 0.6.3__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.6.1 → xcomponent-0.6.3}/CHANGELOG.md +8 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/Cargo.lock +1 -1
- {xcomponent-0.6.1 → xcomponent-0.6.3}/Cargo.toml +1 -1
- {xcomponent-0.6.1 → xcomponent-0.6.3}/PKG-INFO +1 -2
- {xcomponent-0.6.1 → xcomponent-0.6.3}/pyproject.toml +1 -1
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/eval.rs +2 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/grammar.pest +2 -2
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_if_expr.py +23 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/uv.lock +2 -2
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/build-sdist.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/build-wheels.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/publish-doc.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/publish-pypi.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/release.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/tests-artifacts.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/tests.yml +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.gitignore +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/.python-version +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/Justfile +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/LICENSE +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/README.md +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/Makefile +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/conf.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/develop/.gitkeep +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/index.md +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/user/changelog.md +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/user/getting_started.md +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/scripts/get_version.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/scripts/write_changelog.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/__init__.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/py.typed +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/service/__init__.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/service/catalog.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/xcore.pyi +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/catalog/catalog.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/catalog/mod.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/context.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/mod.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/model.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/parse.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/mod.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/parser.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/tokens.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/lib.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/grammar.pest +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/mod.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/parser.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/tokens.rs +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/__init__.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/__init__.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/conftest.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_eq.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_op.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_op_bool.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_default_values.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_field_access.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_for_expr.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_func.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_let.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_nested.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_render_comment.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_str_method.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_types.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_unary.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_core.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_named_component.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_attributes.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_context.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals_obj.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals_obj2.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_nested_dict.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_nested_node.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_node.py +0 -0
- {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_script.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xcomponent
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -20,7 +20,6 @@ Requires-Dist: sphinx-autodoc2>=0.5.0,<1 ; extra == 'docs'
|
|
|
20
20
|
Provides-Extra: docs
|
|
21
21
|
License-File: LICENSE
|
|
22
22
|
Summary: A component base template engige - inspired by JSX
|
|
23
|
-
Author: Guillaume Gauvrit <guillaume@gauvr.it>
|
|
24
23
|
Author-email: Guillaume Gauvrit <guillaume@gauvr.it>
|
|
25
24
|
License: MIT
|
|
26
25
|
Requires-Python: >=3.11
|
|
@@ -190,6 +190,8 @@ pub fn eval_ast<'py>(
|
|
|
190
190
|
let value = eval_ast(py, expr, catalog, context)?;
|
|
191
191
|
match (op, value) {
|
|
192
192
|
(UnaryOperator::Not, Literal::Bool(b)) => Ok(Literal::Bool(!b)),
|
|
193
|
+
(UnaryOperator::Not, Literal::Int(i)) => Ok(Literal::Bool(i == 0)),
|
|
194
|
+
(UnaryOperator::Not, Literal::Str(s)) => Ok(Literal::Bool(s.len() == 0)),
|
|
193
195
|
(UnaryOperator::Not, other) => Err(PyErr::new::<pyo3::exceptions::PyTypeError, _>(
|
|
194
196
|
format!("Cannot apply 'not' to {:?}", other),
|
|
195
197
|
)),
|
|
@@ -49,7 +49,7 @@ comment_expression = _{ "/*" ~ comment ~ "*/" }
|
|
|
49
49
|
comment = { (!"*/" ~ ANY)* }
|
|
50
50
|
|
|
51
51
|
component = { markup_element | markup_fragment }
|
|
52
|
-
markup_node
|
|
52
|
+
markup_node = _{ markup_element | markup_fragment | markup_comment | markup_text | markup_expression }
|
|
53
53
|
markup_element = _{ markup_self_closing_element | markup_normal_element }
|
|
54
54
|
|
|
55
55
|
markup_normal_element = {
|
|
@@ -65,7 +65,7 @@ markup_open_fragment = _{ "<>" }
|
|
|
65
65
|
markup_close_fragment = _{ "</>" }
|
|
66
66
|
markup_attribute = _{ markup_attr_name ~ ("=" ~ markup_attr_value)? }
|
|
67
67
|
markup_comment = _{ "<!--" ~ (!"-->" ~ ANY)* ~ "-->" }
|
|
68
|
-
markup_expression = _{ "{" ~
|
|
68
|
+
markup_expression = _{ "{" ~ whitespace* ~ expression ~ whitespace* ~ "}" }
|
|
69
69
|
|
|
70
70
|
markup_ident = @{ ASCII_ALPHANUMERIC ~ (ASCII_ALPHANUMERIC | "_" )* }
|
|
71
71
|
markup_attr_name = @{ (ASCII_ALPHA | "_" ) ~ (ASCII_ALPHANUMERIC | "_" | "-" | ":" | "." )* }
|
|
@@ -45,6 +45,21 @@ def IfComponent(a: bool) -> str:
|
|
|
45
45
|
return """<>{if a { <p>Ha ha!</p> } }</>"""
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
@catalog.component
|
|
49
|
+
def Hint(text: str | None = None) -> str:
|
|
50
|
+
return """
|
|
51
|
+
<>
|
|
52
|
+
{
|
|
53
|
+
if text {
|
|
54
|
+
<span>
|
|
55
|
+
{text}
|
|
56
|
+
</span>
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</>
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
|
|
48
63
|
@pytest.mark.parametrize(
|
|
49
64
|
"result,expected",
|
|
50
65
|
[
|
|
@@ -56,12 +71,20 @@ def IfComponent(a: bool) -> str:
|
|
|
56
71
|
pytest.param(IfNotStmt(True, "Yes"), "<p></p>"),
|
|
57
72
|
pytest.param(IfNotElseStmt(True, "No", "Yes"), "<p>Yes</p>"),
|
|
58
73
|
pytest.param(IfNotElseStmt(False, "No", "Yes"), "<p>No</p>"),
|
|
74
|
+
pytest.param(IfNotElseStmt(0, "No", "Yes"), "<p>No</p>"),
|
|
75
|
+
pytest.param(IfNotElseStmt(1, "No", "Yes"), "<p>Yes</p>"),
|
|
76
|
+
pytest.param(IfNotElseStmt(42, "No", "Yes"), "<p>Yes</p>"),
|
|
77
|
+
pytest.param(IfNotElseStmt("", "No", "Yes"), "<p>No</p>"),
|
|
78
|
+
pytest.param(IfNotElseStmt("0", "No", "Yes"), "<p>Yes</p>"),
|
|
79
|
+
pytest.param(IfNotElseStmt("that's it", "No", "Yes"), "<p>Yes</p>"),
|
|
59
80
|
pytest.param(IfListStmt(["a"], "b"), "<p>a</p>"),
|
|
60
81
|
pytest.param(IfListStmt([], "b"), "<p>b</p>"),
|
|
61
82
|
pytest.param(IfSelfClosedComponent(True), "<p>Ha ha!</p>"),
|
|
62
83
|
pytest.param(IfSelfClosedComponent(False), ""),
|
|
63
84
|
pytest.param(IfComponent(True), "<p>Ha ha!</p>"),
|
|
64
85
|
pytest.param(IfComponent(False), ""),
|
|
86
|
+
pytest.param(Hint(), ""),
|
|
87
|
+
pytest.param(Hint("I exist"), "<span>I exist</span>"),
|
|
65
88
|
],
|
|
66
89
|
)
|
|
67
90
|
def test_if(result: str, expected: str):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
version = 1
|
|
2
|
-
revision =
|
|
2
|
+
revision = 3
|
|
3
3
|
requires-python = ">=3.11"
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
@@ -598,7 +598,7 @@ wheels = [
|
|
|
598
598
|
|
|
599
599
|
[[package]]
|
|
600
600
|
name = "xcomponent"
|
|
601
|
-
version = "0.6.
|
|
601
|
+
version = "0.6.3"
|
|
602
602
|
source = { editable = "." }
|
|
603
603
|
|
|
604
604
|
[package.optional-dependencies]
|
|
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
|