Skip to content

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