Skip to content

Commit 3c997e6

Browse files
GuillaumeGomezsyphar
authored andcommitted
Remove unused code in IconType::filter
1 parent 45c814a commit 3c997e6

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

src/web/page/templates.rs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -262,30 +262,12 @@ impl fmt::Display for IconType {
262262

263263
impl tera::Filter for IconType {
264264
fn filter(&self, value: &Value, args: &HashMap<String, Value>) -> TeraResult<Value> {
265-
let mut aria_hidden = true;
266265
let icon_name = tera::escape_html(value.as_str().expect("Icons only take strings"));
267266
let class = if args.get("fw").and_then(|fw| fw.as_bool()).unwrap_or(false) {
268267
"fa-svg fa-svg-fw"
269268
} else {
270269
"fa-svg"
271270
};
272-
let aria_label = args
273-
.get("aria-label")
274-
.and_then(|l| l.as_str())
275-
.map(|label| {
276-
aria_hidden = false;
277-
format!(r#" aria_label="{}""#, tera::escape_html(label))
278-
})
279-
.unwrap_or_default();
280-
let id = args
281-
.get("id")
282-
.and_then(|l| l.as_str())
283-
.map(|id| format!(r#" id="{}""#, tera::escape_html(id)))
284-
.unwrap_or_default();
285-
aria_hidden = args
286-
.get("aria-hidden")
287-
.and_then(|l| l.as_bool())
288-
.unwrap_or(aria_hidden);
289271

290272
let type_ = match self {
291273
IconType::Strong => font_awesome_as_a_crate::Type::Solid,
@@ -294,17 +276,14 @@ impl tera::Filter for IconType {
294276
};
295277

296278
let icon_file_string = font_awesome_as_a_crate::svg(type_, &icon_name[..]).unwrap_or("");
279+
let (space, class_extra) = match args.get("extra").and_then(|s| s.as_str()) {
280+
Some(extra) => (" ", extra),
281+
None => ("", ""),
282+
};
297283

298284
let icon = format!(
299-
"<span \
300-
class=\"{class} {class_extra}\" \
301-
aria-hidden=\"{aria_hidden}\"{aria_label}{id}>{icon_file_string}</span>",
302-
icon_file_string = icon_file_string,
303-
class = class,
304-
class_extra = args.get("extra").and_then(|s| s.as_str()).unwrap_or(""),
305-
aria_hidden = aria_hidden,
306-
aria_label = aria_label,
307-
id = id,
285+
"\
286+
<span class=\"{class}{space}{class_extra}\" aria-hidden=\"true\">{icon_file_string}</span>"
308287
);
309288

310289
Ok(Value::String(icon))

0 commit comments

Comments
 (0)