-
-
Notifications
You must be signed in to change notification settings - Fork 37
Add more form attributes #352
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
base: master
Are you sure you want to change the base?
Changes from all commits
4a4e498
89708fa
3a2b7ae
ae395e2
e6b2f3d
e027797
c7ba160
8b21224
fe86f68
6eb7fee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -189,6 +189,37 @@ impl HtmlTag { | |||
| input | ||||
| } | ||||
|
|
||||
| /// Creates a new `HtmlTag` instance for a datalist element. | ||||
| /// | ||||
| /// # Examples | ||||
| /// ``` | ||||
| /// use cot::html::HtmlTag; | ||||
| /// let data_list = HtmlTag::data_list(vec!["Option 1", "Option 2"], "my-datalist"); | ||||
| /// let rendered = data_list.render(); | ||||
| /// ``` | ||||
| #[must_use] | ||||
| pub fn data_list<I, S>(list: I, id: &str) -> Self | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we should force providing |
||||
| where | ||||
| I: IntoIterator<Item = S>, | ||||
| S: AsRef<str>, | ||||
| { | ||||
| let mut data_list = Self::new("datalist"); | ||||
| data_list.attr("id", id); | ||||
|
|
||||
| let mut options: Vec<HtmlNode> = Vec::new(); | ||||
|
|
||||
| for item in list { | ||||
| let l = item.as_ref(); | ||||
| let mut option = HtmlTag::new("option"); | ||||
| option.attr("value", l); | ||||
| option.push_str(l); | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I look in the MDN docs and HTML standard,
Suggested change
|
||||
| options.push(HtmlNode::Tag(option)); | ||||
| } | ||||
|
|
||||
| data_list.children = options; | ||||
| data_list | ||||
| } | ||||
|
|
||||
| /// Adds an attribute to the HTML tag. | ||||
| /// | ||||
| /// # Safety | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: