Skip to content

Commit 6a7aecc

Browse files
committed
Used CRTP to remove component names
Brought back component ID hashing.
1 parent a772bff commit 6a7aecc

File tree

4 files changed

+225
-148
lines changed

4 files changed

+225
-148
lines changed

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,34 @@ int main () {
5252

5353
// Bring your own data model:
5454
bool is1MVisit = true;
55-
std::vector<std::string> toDoItems {
56-
"Water plants",
57-
"Plug (memory) leaks",
58-
"Get back to that other project",
59-
};
6055

61-
// Create modular components with scoped CSS:
62-
component toDoList {
63-
"toDoList",
64-
// Styles apply only to the component's elements:
65-
{
66-
{"ul",
67-
// Hyphenated properties are camelCased:
68-
listStyle{ "none" },
56+
// Create modular components which include scoped CSS:
57+
struct ToDoList : component<ToDoList> {
58+
ToDoList (std::vector<std::string> &&toDoItems) : component<ToDoList>{
59+
// Styles apply only to the component's elements:
60+
{
61+
{"ul",
62+
// Hyphenated properties are camelCased:
63+
listStyle{ "none" },
64+
},
6965
},
70-
},
71-
// Component HTML:
72-
dv {
73-
h1 { "To-do:" },
74-
// Iterate over iterators:
75-
ul { each(toDoItems, [] (std::string &item) {
76-
return li { item };
77-
}) },
78-
},
66+
// Component HTML:
67+
dv {
68+
h1 { "To-do:" },
69+
// Iterate over iterators:
70+
ul { each(toDoItems, [] (const std::string &item) {
71+
return li { item };
72+
}) },
73+
},
74+
} {}
7975
};
8076

77+
ToDoList toDoList{{
78+
"Water plants",
79+
"Plug (memory) leaks",
80+
"Get back to that other project",
81+
}};
82+
8183
// Compose a full page:
8284
doc page {
8385
html {

0 commit comments

Comments
 (0)