Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

98 data phx ref support #255

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

mobile-bungalow
Copy link
Contributor

No description provided.

Copy link
Contributor

@simlay simlay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty good. I know there's some merge conflicts due to #256. The changes are deep into the patch diffing that I've avoided.

I think the attr, element, const_attr macros make the tests a lot nicer. I'd just suggest that they be in the test modules.

Comment on lines +7 to +28
#[macro_export]
macro_rules! attr {
($name:literal) => {
Attribute::new($name, None)
};
($name:literal= $value:expr) => {
Attribute::new($name, Some($value.to_string()))
};
($namespace:literal : $name:literal) => {
Attribute {
name: AttributeName::new_with_namespace($namespace, $name),
value: None,
}
};
($namespace:literal : $name:literal = $value:expr) => {
Attribute {
name: AttributeName::new_with_namespace($namespace, $name),
value: Some($value.to_string()),
}
};
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this moment, I think this macro is only used in tests so it should probably go behind a #[cfg(test)] or in a test module.

@@ -309,3 +333,34 @@ impl Element {
}
}
}

#[macro_export]
macro_rules! element {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing about this only being used in tests.

Comment on lines +160 to +166
element!(
"Button",
attr!("id" = "button"),
attr!("phx-click" = "inc_temperature"),
attr!("data-phx-ref-src" = "5"),
attr!("class" = "phx-click-loading")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants