File tree Expand file tree Collapse file tree 3 files changed +35
-39
lines changed
renderer/html_handlebars/helpers Expand file tree Collapse file tree 3 files changed +35
-39
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,7 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
89
89
let input_404 = book
90
90
. config
91
91
. get ( "output.html.input-404" )
92
- . map ( toml:: Value :: as_str)
93
- . and_then ( std:: convert:: identity) // flatten
92
+ . and_then ( toml:: Value :: as_str)
94
93
. map ( ToString :: to_string) ;
95
94
let file_404 = get_404_output_file ( & input_404) ;
96
95
Original file line number Diff line number Diff line change @@ -148,15 +148,12 @@ fn render(
148
148
149
149
trace ! ( "Render template" ) ;
150
150
151
- _h. template ( )
152
- . ok_or_else ( || RenderError :: new ( "Error with the handlebars template" ) )
153
- . and_then ( |t| {
154
- let local_ctx = Context :: wraps ( & context) ?;
155
- let mut local_rc = rc. clone ( ) ;
156
- t. render ( r, & local_ctx, & mut local_rc, out)
157
- } ) ?;
158
-
159
- Ok ( ( ) )
151
+ let t = _h
152
+ . template ( )
153
+ . ok_or_else ( || RenderError :: new ( "Error with the handlebars template" ) ) ?;
154
+ let local_ctx = Context :: wraps ( & context) ?;
155
+ let mut local_rc = rc. clone ( ) ;
156
+ t. render ( r, & local_ctx, & mut local_rc, out)
160
157
}
161
158
162
159
pub fn previous (
Original file line number Diff line number Diff line change @@ -117,35 +117,35 @@ impl HelperDef for RenderToc {
117
117
}
118
118
119
119
// Link
120
- let path_exists = if let Some ( path) =
121
- item. get ( "path" )
122
- . and_then ( |p| if p. is_empty ( ) { None } else { Some ( p) } )
123
- {
124
- out. write ( "<a href=\" " ) ?;
125
-
126
- let tmp = Path :: new ( item. get ( "path" ) . expect ( "Error: path should be Some(_)" ) )
127
- . with_extension ( "html" )
128
- . to_str ( )
129
- . unwrap ( )
130
- // Hack for windows who tends to use `\` as separator instead of `/`
131
- . replace ( '\\' , "/" ) ;
132
-
133
- // Add link
134
- out. write ( & utils:: fs:: path_to_root ( & current_path) ) ?;
135
- out. write ( & tmp) ?;
136
- out. write ( "\" " ) ?;
137
-
138
- if path == & current_path || is_first_chapter {
139
- is_first_chapter = false ;
140
- out. write ( " class=\" active\" " ) ?;
141
- }
120
+ let path_exists: bool ;
121
+ match item. get ( "path" ) {
122
+ Some ( path) if !path. is_empty ( ) => {
123
+ out. write ( "<a href=\" " ) ?;
124
+ let tmp = Path :: new ( path)
125
+ . with_extension ( "html" )
126
+ . to_str ( )
127
+ . unwrap ( )
128
+ // Hack for windows who tends to use `\` as separator instead of `/`
129
+ . replace ( '\\' , "/" ) ;
130
+
131
+ // Add link
132
+ out. write ( & utils:: fs:: path_to_root ( & current_path) ) ?;
133
+ out. write ( & tmp) ?;
134
+ out. write ( "\" " ) ?;
135
+
136
+ if path == & current_path || is_first_chapter {
137
+ is_first_chapter = false ;
138
+ out. write ( " class=\" active\" " ) ?;
139
+ }
142
140
143
- out. write ( ">" ) ?;
144
- true
145
- } else {
146
- out. write ( "<div>" ) ?;
147
- false
148
- } ;
141
+ out. write ( ">" ) ?;
142
+ path_exists = true ;
143
+ }
144
+ _ => {
145
+ out. write ( "<div>" ) ?;
146
+ path_exists = false ;
147
+ }
148
+ }
149
149
150
150
if !self . no_section_label {
151
151
// Section does not necessarily exist
You can’t perform that action at this time.
0 commit comments