xcomponent 0.5.1__tar.gz → 0.5.2__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 (72) hide show
  1. {xcomponent-0.5.1 → xcomponent-0.5.2}/CHANGELOG.md +9 -5
  2. {xcomponent-0.5.1 → xcomponent-0.5.2}/Cargo.lock +1 -1
  3. {xcomponent-0.5.1 → xcomponent-0.5.2}/Cargo.toml +1 -1
  4. {xcomponent-0.5.1 → xcomponent-0.5.2}/PKG-INFO +1 -1
  5. {xcomponent-0.5.1 → xcomponent-0.5.2}/pyproject.toml +2 -1
  6. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/markup/tokens.rs +5 -4
  7. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_attributes.py +57 -0
  8. {xcomponent-0.5.1 → xcomponent-0.5.2}/uv.lock +15 -1
  9. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/build-sdist.yml +0 -0
  10. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/build-wheels.yml +0 -0
  11. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/publish-doc.yml +0 -0
  12. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/publish-pypi.yml +0 -0
  13. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/release.yml +0 -0
  14. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/tests-artifacts.yml +0 -0
  15. {xcomponent-0.5.1 → xcomponent-0.5.2}/.github/workflows/tests.yml +0 -0
  16. {xcomponent-0.5.1 → xcomponent-0.5.2}/.gitignore +0 -0
  17. {xcomponent-0.5.1 → xcomponent-0.5.2}/.python-version +0 -0
  18. {xcomponent-0.5.1 → xcomponent-0.5.2}/Justfile +0 -0
  19. {xcomponent-0.5.1 → xcomponent-0.5.2}/LICENSE +0 -0
  20. {xcomponent-0.5.1 → xcomponent-0.5.2}/README.md +0 -0
  21. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/Makefile +0 -0
  22. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/source/conf.py +0 -0
  23. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/source/develop/.gitkeep +0 -0
  24. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/source/index.md +0 -0
  25. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/source/user/changelog.md +0 -0
  26. {xcomponent-0.5.1 → xcomponent-0.5.2}/docs/source/user/getting_started.md +0 -0
  27. {xcomponent-0.5.1 → xcomponent-0.5.2}/scripts/get_version.py +0 -0
  28. {xcomponent-0.5.1 → xcomponent-0.5.2}/scripts/write_changelog.py +0 -0
  29. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/python/xcomponent/__init__.py +0 -0
  30. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/python/xcomponent/py.typed +0 -0
  31. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/python/xcomponent/service/__init__.py +0 -0
  32. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/python/xcomponent/service/catalog.py +0 -0
  33. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/python/xcomponent/xcore.pyi +0 -0
  34. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/catalog/catalog.rs +0 -0
  35. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/catalog/mod.rs +0 -0
  36. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/context.rs +0 -0
  37. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/ast/eval.rs +0 -0
  38. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/ast/mod.rs +0 -0
  39. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/ast/model.rs +0 -0
  40. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/ast/parse.rs +0 -0
  41. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/grammar.pest +0 -0
  42. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/mod.rs +0 -0
  43. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/parser.rs +0 -0
  44. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/expression/tokens.rs +0 -0
  45. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/lib.rs +0 -0
  46. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/markup/grammar.pest +0 -0
  47. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/markup/mod.rs +0 -0
  48. {xcomponent-0.5.1 → xcomponent-0.5.2}/src/rust/markup/parser.rs +0 -0
  49. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/__init__.py +0 -0
  50. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/__init__.py +0 -0
  51. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_binary_eq.py +0 -0
  52. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_binary_op.py +0 -0
  53. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_binary_op_bool.py +0 -0
  54. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_default_values.py +0 -0
  55. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_field_access.py +0 -0
  56. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_for_expr.py +0 -0
  57. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_func.py +0 -0
  58. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_if_expr.py +0 -0
  59. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_nested.py +0 -0
  60. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_render_comment.py +0 -0
  61. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_types.py +0 -0
  62. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/expression/test_unary.py +0 -0
  63. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_core.py +0 -0
  64. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_named_component.py +0 -0
  65. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_context.py +0 -0
  66. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_globals.py +0 -0
  67. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_globals_obj.py +0 -0
  68. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_globals_obj2.py +0 -0
  69. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_nested_dict.py +0 -0
  70. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_nested_node.py +0 -0
  71. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_node.py +0 -0
  72. {xcomponent-0.5.1 → xcomponent-0.5.2}/tests/unittests/test_render_script.py +0 -0
@@ -1,16 +1,20 @@
1
+ ## 0.5.2 - 2025-06-03
2
+
3
+ * Hotfix component havin attributes'name containing python reserved keyword.
4
+
1
5
  ## 0.5.1 - 2025-06-02
2
6
 
3
- * Preserve empty string in markup such as stript tag to render
4
- * Fix rendering of json in attributes such as hx-vals
5
- * Check mypy in the CI
7
+ * Preserve empty string in markup such as stript tag to render.
8
+ * Fix rendering of json in attributes such as hx-vals.
9
+ * Check mypy in the CI.
6
10
 
7
11
  ## 0.5.0 - 2025-05-31
8
12
 
9
13
  * Improve html attributes supports.
10
14
  * hyphen can be used in markup language and is bound
11
15
  to underscore variable in python.
12
- * attribute for is bound to for_
13
- * attribute class is bount to class_
16
+ * attribute for is bound to for_.
17
+ * attribute class is bount to class_.
14
18
 
15
19
  ## 0.4.1 - 2025-05-30
16
20
 
@@ -595,7 +595,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
595
595
 
596
596
  [[package]]
597
597
  name = "xcore"
598
- version = "0.5.1"
598
+ version = "0.5.2"
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.5.1"
3
+ version = "0.5.2"
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.5.1
3
+ Version: 0.5.2
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xcomponent"
3
- version = "0.5.1"
3
+ version = "0.5.2"
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" }]
@@ -40,6 +40,7 @@ docs = [
40
40
 
41
41
  [dependency-groups]
42
42
  dev = [
43
+ "bs4>=0.0.2",
43
44
  "mypy >=1.16.0,<2",
44
45
  "pytest >=8.3.5,<9",
45
46
  ]
@@ -144,10 +144,11 @@ impl ToHtml for XElement {
144
144
  .copy()?;
145
145
 
146
146
  for (name, attrnode) in self.attrs() {
147
- let name = name
148
- .replace('-', "_")
149
- .replace("class", "class_")
150
- .replace("for", "for_");
147
+ let name = match name.as_str() {
148
+ "class" => "class_".to_string(),
149
+ "for" => "for_".to_string(),
150
+ _ => name.replace('-', "_"),
151
+ };
151
152
  if let XNode::Expression(ref expression) = attrnode {
152
153
  let node_attr_v =
153
154
  eval_expression(py, expression.expression(), &catalog, context)?;
@@ -2,6 +2,7 @@ from typing import Literal
2
2
  from xcomponent import Catalog, XNode
3
3
 
4
4
  import pytest
5
+ import bs4
5
6
 
6
7
  catalog = Catalog()
7
8
 
@@ -46,6 +47,34 @@ def Button(hx_vals: str) -> str:
46
47
  """
47
48
 
48
49
 
50
+ @catalog.component
51
+ def Radio(
52
+ globals: dict[str, str],
53
+ label: str,
54
+ name: str,
55
+ value: str,
56
+ id: str | None = None,
57
+ checked: bool = False,
58
+ disabled: bool = False,
59
+ onclick: str | None = None,
60
+ div_class: str | None = None,
61
+ class_: str | None = None,
62
+ label_class: str | None = None,
63
+ ) -> str:
64
+ return """
65
+ <div class={div_class or globals.RADIO_DIV_CLASS}>
66
+ <input type="radio" name={name} id={id} value={value}
67
+ class={class_ or globals.RADIO_INPUT_CLASS}
68
+ onclick={onclick}
69
+ checked={checked}
70
+ disabled={disabled} />
71
+ <Label for={id} class={label_class or globals.RADIO_LABEL_CLASS}>
72
+ {label}
73
+ </Label>
74
+ </div>
75
+ """
76
+
77
+
49
78
  @pytest.mark.parametrize(
50
79
  "component,expected",
51
80
  [
@@ -99,3 +128,31 @@ def test_render_form(component: str, expected: str):
99
128
  )
100
129
  def test_render_double_quote_in_quote(component: str, expected: str):
101
130
  assert component == expected
131
+
132
+
133
+ @pytest.mark.parametrize(
134
+ "component,expected",
135
+ [
136
+ pytest.param(
137
+ catalog.render(
138
+ """
139
+ <Radio name="n" value="v"
140
+ label="lbl" class="radio" label-class="lbl" div-class="d" />
141
+ """,
142
+ globals={
143
+ "RADIO_DIV_CLASS": "RADIO_DIV_CLASS",
144
+ "RADIO_INPUT_CLASS": "RADIO_INPUT_CLASS",
145
+ "RADIO_LABEL_CLASS": "RADIO_LABEL_CLASS",
146
+ },
147
+ ),
148
+ '<div class="d"><input type="radio" name="n" class="radio" value="v"/>'
149
+ '<label class="lbl">lbl</label></div>',
150
+ id="dont alter suffixed by class",
151
+ )
152
+ ],
153
+ )
154
+ def test_render_suffixed_class(component: str, expected: str):
155
+ soup = bs4.BeautifulSoup(component, "html.parser")
156
+ expected_soup = bs4.BeautifulSoup(expected, "html.parser")
157
+
158
+ assert next(soup.children) == next(expected_soup.children)
@@ -42,6 +42,18 @@ wheels = [
42
42
  { url = "https://files.pythonhosted.org/packages/50/cd/30110dc0ffcf3b131156077b90e9f60ed75711223f306da4db08eff8403b/beautifulsoup4-4.13.4-py3-none-any.whl", hash = "sha256:9bbbb14bfde9d79f38b8cd5f8c7c85f4b8f2523190ebed90e950a8dea4cb1c4b", size = 187285, upload-time = "2025-04-15T17:05:12.221Z" },
43
43
  ]
44
44
 
45
+ [[package]]
46
+ name = "bs4"
47
+ version = "0.0.2"
48
+ source = { registry = "https://pypi.org/simple" }
49
+ dependencies = [
50
+ { name = "beautifulsoup4" },
51
+ ]
52
+ sdist = { url = "https://files.pythonhosted.org/packages/c9/aa/4acaf814ff901145da37332e05bb510452ebed97bc9602695059dd46ef39/bs4-0.0.2.tar.gz", hash = "sha256:a48685c58f50fe127722417bae83fe6badf500d54b55f7e39ffe43b798653925", size = 698, upload-time = "2024-01-17T18:15:47.371Z" }
53
+ wheels = [
54
+ { url = "https://files.pythonhosted.org/packages/51/bb/bf7aab772a159614954d84aa832c129624ba6c32faa559dfb200a534e50b/bs4-0.0.2-py2.py3-none-any.whl", hash = "sha256:abf8742c0805ef7f662dce4b51cca104cffe52b835238afc169142ab9b3fbccc", size = 1189, upload-time = "2024-01-17T18:15:48.613Z" },
55
+ ]
56
+
45
57
  [[package]]
46
58
  name = "certifi"
47
59
  version = "2025.4.26"
@@ -576,7 +588,7 @@ wheels = [
576
588
 
577
589
  [[package]]
578
590
  name = "xcomponent"
579
- version = "0.5.1"
591
+ version = "0.5.2"
580
592
  source = { editable = "." }
581
593
 
582
594
  [package.optional-dependencies]
@@ -590,6 +602,7 @@ docs = [
590
602
 
591
603
  [package.dev-dependencies]
592
604
  dev = [
605
+ { name = "bs4" },
593
606
  { name = "mypy" },
594
607
  { name = "pytest" },
595
608
  ]
@@ -613,6 +626,7 @@ provides-extras = ["docs"]
613
626
 
614
627
  [package.metadata.requires-dev]
615
628
  dev = [
629
+ { name = "bs4", specifier = ">=0.0.2" },
616
630
  { name = "mypy", specifier = ">=1.16.0,<2" },
617
631
  { name = "pytest", specifier = ">=8.3.5,<9" },
618
632
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes