File tree Expand file tree Collapse file tree 4 files changed +225
-148
lines changed Expand file tree Collapse file tree 4 files changed +225
-148
lines changed Original file line number Diff line number Diff line change @@ -52,32 +52,34 @@ int main () {
52
52
53
53
// Bring your own data model:
54
54
bool is1MVisit = true;
55
- std::vector<std::string> toDoItems {
56
- "Water plants",
57
- "Plug (memory) leaks",
58
- "Get back to that other project",
59
- };
60
55
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
+ },
69
65
},
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
+ } {}
79
75
};
80
76
77
+ ToDoList toDoList{{
78
+ "Water plants",
79
+ "Plug (memory) leaks",
80
+ "Get back to that other project",
81
+ }};
82
+
81
83
// Compose a full page:
82
84
doc page {
83
85
html {
You can’t perform that action at this time.
0 commit comments