-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to use nested components
Update hierarch separator from "/" to "|" and type separator from "." to ":". With this change, components with "nested/types" (e.g., "myapp/mycomponent") can be used with livecomponents and form the full path that can be parsed. Update "coffee" example to use "coffee/<something>" component names.
- Loading branch information
Showing
21 changed files
with
107 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
# The full ID look like this: | ||
# "parent-type.parent-id/child-type.child-id" | ||
|
||
# HTMX doesn't escape query selectors, so elsewhere in the code we | ||
# have to explicitly oass the escape the "hx-swap-oob" attributes | ||
# as "hx-swap-oob="morph:#parent-type\.parent-id\/child-type\.child-id" | ||
# https://github.com/bigskysoftware/htmx/issues/1537 | ||
|
||
# We chose dot and slash as separators because this way we can leverage | ||
# pathlib.PosixPath to parse it. | ||
# We can use "stem" and "suffix" to get the component type and ID | ||
|
||
HIER_SEP = "/" | ||
TYPE_SEP = "." | ||
# "|parent-type:parent-id|child-type:child-id" | ||
# | ||
# | ||
# A few things to note: | ||
# - We use LiveComponentsPath() to parse it. | ||
# - We intentionally don't use "/" as the hierarchy separator because we want to use | ||
# components that have "/" in their names. See "coffee/row" for example. | ||
HIER_SEP = "|" | ||
TYPE_SEP = ":" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from livecomponents.templatetags.livecomponents import component_id | ||
|
||
|
||
def test_component_id(): | ||
assert ( | ||
component_id("table", "primary", "row", 1, "cell", "x") | ||
== "|table:primary|row:1|cell:x" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# LiveComponentsPath | ||
from livecomponents.utils import LiveComponentsPath | ||
|
||
|
||
def test_live_components_path(): | ||
path = LiveComponentsPath("|foo:bar|baz:spam") | ||
assert path.stem == "baz" | ||
assert str(path.parent) == "|foo:bar" | ||
assert str(path.parent.parent) == "|" |