Debian Codegraph @

tests/embed.rs

raw symbols SCIP
1 #[macro_use]
2 extern crate serde_jsonrust-analyzer cargo handlebars 5.1.2 serde_json/;
3
4 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5 #[cfg(feature = "rust-embed")]
6 fn test_embedrust-analyzer cargo handlebars 5.1.2 test_embed().() {
7 use rust_embedrust-analyzer cargo rust-embed 8.3.0 crate/::RustEmbedrust-analyzer cargo rust-embed 8.3.0 RustEmbed#;
8
9 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(RustEmbedrust-analyzer cargo rust-embed-impl 8.3.0 RustEmbed:)]
10 #[folder = "tests/templates/"]
11 #[includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include! = "*.hbs"]
12 struct Templatesrust-analyzer cargo handlebars 5.1.2 Templates#;
13
14 let mut hbs = handlebarsrust-analyzer cargo handlebars 5.1.2 crate/::Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().();
15 hbs.register_embed_templatesrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_embed_templates().::<Templatesrust-analyzer cargo handlebars 5.1.2 Templates#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
16
17 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(1, hbs.get_templatesrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_templates().().lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().());
18
19 let data = jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({
20 "name": "Andy"
21 });
22
23 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
24 hbs.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("hello.hbs", &data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(),
25 "Hello, Andy"
26 );
27 }
28
29 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
30 #[cfg(feature = "rust-embed")]
31 fn test_embed_with_extensionrust-analyzer cargo handlebars 5.1.2 test_embed_with_extension().() {
32 use rust_embedrust-analyzer cargo rust-embed 8.3.0 crate/::RustEmbedrust-analyzer cargo rust-embed 8.3.0 RustEmbed#;
33
34 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(RustEmbedrust-analyzer cargo rust-embed-impl 8.3.0 RustEmbed:)]
35 #[folder = "tests/templates/"]
36 struct Templatesrust-analyzer cargo handlebars 5.1.2 Templates#;
37
38 let mut hbs = handlebarsrust-analyzer cargo handlebars 5.1.2 crate/::Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().();
39 hbs.register_embed_templates_with_extensionrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_embed_templates_with_extension().::<Templatesrust-analyzer cargo handlebars 5.1.2 Templates#>(".hbs")
40 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
41
42 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(1, hbs.get_templatesrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_templates().().lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().());
43
44 let data = jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({
45 "name": "Andy"
46 });
47
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hbs.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("hello", &data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(), "Hello, Andy");
49 }
50
51 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
52 #[cfg(feature = "rust-embed")]
53 fn test_embed_with_extension_and_tests_struct_rootrust-analyzer cargo handlebars 5.1.2 test_embed_with_extension_and_tests_struct_root().() {
54 use rust_embedrust-analyzer cargo rust-embed 8.3.0 crate/::RustEmbedrust-analyzer cargo rust-embed 8.3.0 RustEmbed#;
55
56 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(RustEmbedrust-analyzer cargo rust-embed-impl 8.3.0 RustEmbed:)]
57 #[folder = "tests/"]
58 struct Templatesrust-analyzer cargo handlebars 5.1.2 Templates#;
59
60 let mut hbs = handlebarsrust-analyzer cargo handlebars 5.1.2 crate/::Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().();
61 hbs.register_embed_templates_with_extensionrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_embed_templates_with_extension().::<Templatesrust-analyzer cargo handlebars 5.1.2 Templates#>(".hbs")
62 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
63
64 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(1, hbs.get_templatesrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_templates().().lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().());
65
66 let data = jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({
67 "name": "Andy"
68 });
69
70 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
71 hbs.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("templates/hello", &data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(),
72 "Hello, Andy"
73 );
74 }