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.
Files changed (75) hide show
  1. {xcomponent-0.6.1 → xcomponent-0.6.3}/CHANGELOG.md +8 -0
  2. {xcomponent-0.6.1 → xcomponent-0.6.3}/Cargo.lock +1 -1
  3. {xcomponent-0.6.1 → xcomponent-0.6.3}/Cargo.toml +1 -1
  4. {xcomponent-0.6.1 → xcomponent-0.6.3}/PKG-INFO +1 -2
  5. {xcomponent-0.6.1 → xcomponent-0.6.3}/pyproject.toml +1 -1
  6. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/eval.rs +2 -0
  7. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/grammar.pest +2 -2
  8. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_if_expr.py +23 -0
  9. {xcomponent-0.6.1 → xcomponent-0.6.3}/uv.lock +2 -2
  10. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/build-sdist.yml +0 -0
  11. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/build-wheels.yml +0 -0
  12. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/publish-doc.yml +0 -0
  13. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/publish-pypi.yml +0 -0
  14. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/release.yml +0 -0
  15. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/tests-artifacts.yml +0 -0
  16. {xcomponent-0.6.1 → xcomponent-0.6.3}/.github/workflows/tests.yml +0 -0
  17. {xcomponent-0.6.1 → xcomponent-0.6.3}/.gitignore +0 -0
  18. {xcomponent-0.6.1 → xcomponent-0.6.3}/.python-version +0 -0
  19. {xcomponent-0.6.1 → xcomponent-0.6.3}/Justfile +0 -0
  20. {xcomponent-0.6.1 → xcomponent-0.6.3}/LICENSE +0 -0
  21. {xcomponent-0.6.1 → xcomponent-0.6.3}/README.md +0 -0
  22. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/Makefile +0 -0
  23. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/conf.py +0 -0
  24. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/develop/.gitkeep +0 -0
  25. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/index.md +0 -0
  26. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/user/changelog.md +0 -0
  27. {xcomponent-0.6.1 → xcomponent-0.6.3}/docs/source/user/getting_started.md +0 -0
  28. {xcomponent-0.6.1 → xcomponent-0.6.3}/scripts/get_version.py +0 -0
  29. {xcomponent-0.6.1 → xcomponent-0.6.3}/scripts/write_changelog.py +0 -0
  30. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/__init__.py +0 -0
  31. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/py.typed +0 -0
  32. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/service/__init__.py +0 -0
  33. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/service/catalog.py +0 -0
  34. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/python/xcomponent/xcore.pyi +0 -0
  35. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/catalog/catalog.rs +0 -0
  36. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/catalog/mod.rs +0 -0
  37. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/context.rs +0 -0
  38. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/mod.rs +0 -0
  39. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/model.rs +0 -0
  40. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/ast/parse.rs +0 -0
  41. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/mod.rs +0 -0
  42. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/parser.rs +0 -0
  43. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/expression/tokens.rs +0 -0
  44. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/lib.rs +0 -0
  45. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/grammar.pest +0 -0
  46. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/mod.rs +0 -0
  47. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/parser.rs +0 -0
  48. {xcomponent-0.6.1 → xcomponent-0.6.3}/src/rust/markup/tokens.rs +0 -0
  49. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/__init__.py +0 -0
  50. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/__init__.py +0 -0
  51. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/conftest.py +0 -0
  52. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_eq.py +0 -0
  53. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_op.py +0 -0
  54. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_binary_op_bool.py +0 -0
  55. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_default_values.py +0 -0
  56. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_field_access.py +0 -0
  57. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_for_expr.py +0 -0
  58. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_func.py +0 -0
  59. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_let.py +0 -0
  60. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_nested.py +0 -0
  61. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_render_comment.py +0 -0
  62. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_str_method.py +0 -0
  63. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_types.py +0 -0
  64. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/expression/test_unary.py +0 -0
  65. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_core.py +0 -0
  66. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_named_component.py +0 -0
  67. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_attributes.py +0 -0
  68. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_context.py +0 -0
  69. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals.py +0 -0
  70. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals_obj.py +0 -0
  71. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_globals_obj2.py +0 -0
  72. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_nested_dict.py +0 -0
  73. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_nested_node.py +0 -0
  74. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_node.py +0 -0
  75. {xcomponent-0.6.1 → xcomponent-0.6.3}/tests/unittests/test_render_script.py +0 -0
@@ -1,3 +1,11 @@
1
+ ## 0.6.3 - 2025-08-30
2
+
3
+ * Implement not operator for str and int
4
+
5
+ ## 0.6.2 - 2025-08-15
6
+
7
+ * Fix nested var in if stmt
8
+
1
9
  ## 0.6.1 - 2025-06-13
2
10
 
3
11
  * Authorize full markup inside statement instead of self closed element only.
@@ -595,7 +595,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
595
595
 
596
596
  [[package]]
597
597
  name = "xcore"
598
- version = "0.6.1"
598
+ version = "0.6.3"
599
599
  dependencies = [
600
600
  "env_logger",
601
601
  "html-escape",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "xcore"
3
- version = "0.6.1"
3
+ version = "0.6.3"
4
4
  authors = ["Guillaume Gauvrit <guillaume@gauvr.it>"]
5
5
  edition = "2021"
6
6
  description = "JSX-like for python using maturin/pyo3 and pest."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xcomponent
3
- Version: 0.6.1
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xcomponent"
3
- version = "0.6.1"
3
+ version = "0.6.3"
4
4
  description = "A component base template engige - inspired by JSX"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Guillaume Gauvrit", email = "guillaume@gauvr.it" }]
@@ -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 = _{ markup_element | markup_fragment | markup_comment | markup_text }
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 = _{ "{" ~ (markup_expression | (!"}" ~ ANY))* ~ "}" }
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
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.1"
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