1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Keyword handles for `{ ... }` expressions in the [`view!`](crate::view) macro.
use crate;
use crateList;
use crateView;
/// `{ for ... }`: turn an [`IntoIterator`](IntoIterator) type into a [`View`](View).
///
/// ```
/// # use kobold::prelude::*;
/// view! {
/// <h1>"Integers 1 to 10:"</h1>
/// <ul>
/// { for (1..=10).map(|n| view! { <li>{ n }</li> }) }
/// </ul>
/// }
/// # ;
/// ```
pub const #for<T> where
T: IntoIterator,
Item: View,
/// `{ ref ... }`: diff this value by its reference address.
///
/// For strings this is both faster and more memory efficient (no allocations necessary),
/// however it might fail to update if underlying memory has been mutated in place without
/// re-allocations.
/// ```
/// use kobold::prelude::*;
///
/// struct User {
/// name: String,
/// email: String,
/// }
///
/// #[component]
/// fn UserRow(user: &User) -> impl View + '_ {
/// view! {
/// <tr>
/// // If `name` and `email` are always sent to the UI as
/// // newly allocated `String`s, it's both safe and faster
/// // to diff them by reference than value.
/// <td>{ ref user.name }</td>
/// <td>{ ref user.email }</td>
/// </tr>
/// }
/// }
/// ```
pub const #ref
/// `{ use ... }`: disable diffing for `T` and apply its value to the DOM on every render.
///
/// This is usually not advised, but can be useful when combined with [`fence`](crate::diff::fence).
pub const #use<T>
/// `{ static ... }` disable diffing for `T` and never update its value in the DOM after the initial render.
pub const #static<T>