mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
template_filters: make {{type:}} forwards compatible (#3525)
Make Anki treat {{type:unknown:field}} field replacements as {{type:field}} instead of {{field}}. The previous behavior was seriously inconvenient for several reasons, including: * Updated client aren't all released at the same time, causing an unavoidable mismatch period. Now it causes the least friction. * Devs couldn't readily test new in-dev variants without breaking/inconveniencing their own mobile experience. * Some users will have (potentially perpetually) outdated Anki clients and likely complain, wasting both dev & deck creator time. This way users always get to type and especially: The front side will always render as intended.
This commit is contained in:
parent
e4eaaa57ab
commit
0513940305
1 changed files with 10 additions and 6 deletions
|
@ -31,12 +31,12 @@ pub(crate) fn apply_filters<'a>(
|
|||
let mut text: Cow<str> = text.into();
|
||||
|
||||
// type:cloze & type:nc are handled specially
|
||||
let filters = if filters == ["cloze", "type"] {
|
||||
&["type-cloze"]
|
||||
} else if filters == ["nc", "type"] {
|
||||
&["type-nc"]
|
||||
} else {
|
||||
filters
|
||||
// other type: are passed as the default one
|
||||
let filters = match filters {
|
||||
["cloze", "type"] => &["type-cloze"],
|
||||
["nc", "type"] => &["type-nc"],
|
||||
[.., "type"] => &["type"],
|
||||
_ => filters,
|
||||
};
|
||||
|
||||
for (idx, &filter_name) in filters.iter().enumerate() {
|
||||
|
@ -259,6 +259,10 @@ field</a>
|
|||
apply_filters("ignored", &["nc", "type"], "Text", &ctx),
|
||||
("[[type:nc:Text]]".into(), vec![])
|
||||
);
|
||||
assert_eq!(
|
||||
apply_filters("ignored", &["some", "unknown", "type"], "Text", &ctx),
|
||||
("[[type:Text]]".into(), vec![])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue