File tree 2 files changed +35
-0
lines changed
crates/rari-doc/src/templ/templs
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: fmt:: Write ;
2
+
3
+ use rari_templ_func:: rari_f;
4
+ use rari_types:: AnyArg ;
5
+
6
+ use crate :: error:: DocError ;
7
+
8
+ #[ rari_f]
9
+ pub fn embed_gh_live_sample (
10
+ path : String ,
11
+ width : Option < AnyArg > ,
12
+ height : Option < AnyArg > ,
13
+ ) -> Result < String , DocError > {
14
+ let mut out = String :: new ( ) ;
15
+ out. push_str ( "<iframe " ) ;
16
+ if let Some ( width) = width {
17
+ if !width. is_empty ( ) {
18
+ write ! ( & mut out, r#"width="{}" "# , width) ?;
19
+ }
20
+ }
21
+ if let Some ( height) = height {
22
+ if !height. is_empty ( ) {
23
+ write ! ( & mut out, r#"height="{}" "# , height) ?;
24
+ }
25
+ }
26
+
27
+ out. extend ( [
28
+ r#"src="https://mdn.github.io/"# ,
29
+ path. as_str ( ) ,
30
+ r#""></iframe>"# ,
31
+ ] ) ;
32
+ Ok ( out)
33
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ pub mod banners;
4
4
pub mod compat;
5
5
pub mod cssinfo;
6
6
pub mod csssyntax;
7
+ pub mod embedghlivesample;
7
8
pub mod embedinteractiveexample;
8
9
pub mod glossary;
9
10
pub mod inheritance_diagram;
@@ -34,6 +35,7 @@ pub fn invoke(
34
35
"glossary" => glossary:: glossary_any,
35
36
"csssyntax" => csssyntax:: csssyntax_any,
36
37
"embedinteractiveexample" => embedinteractiveexample:: embed_interactive_example_any,
38
+ "embedghlivesample" => embedghlivesample:: embed_gh_live_sample_any,
37
39
"listsubpages" => listsubpages:: list_sub_pages_any,
38
40
"listsubpagesgrouped" => listsubpages:: list_sub_pages_grouped_any,
39
41
"embedlivesample" => livesample:: live_sample_any,
You can’t perform that action at this time.
0 commit comments