mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Allow empty field name in templates
This commit is contained in:
parent
c6e78e6f21
commit
33bf391114
2 changed files with 8 additions and 6 deletions
|
@ -143,6 +143,10 @@ def test_furigana():
|
||||||
n["Front"] = "foo[sound:abc.mp3]"
|
n["Front"] = "foo[sound:abc.mp3]"
|
||||||
n.flush()
|
n.flush()
|
||||||
assert "anki:play" in c.q(reload=True)
|
assert "anki:play" in c.q(reload=True)
|
||||||
|
# it shouldn't throw an error while people are editing
|
||||||
|
m["tmpls"][0]["qfmt"] = "{{kana:}}"
|
||||||
|
mm.save(m)
|
||||||
|
c.q(reload=True)
|
||||||
|
|
||||||
|
|
||||||
def test_translate():
|
def test_translate():
|
||||||
|
|
|
@ -338,12 +338,10 @@ impl Notetype {
|
||||||
"Type",
|
"Type",
|
||||||
];
|
];
|
||||||
names.into_iter().any(|name| {
|
names.into_iter().any(|name| {
|
||||||
!special_fields.contains(&name.as_ref())
|
// The empty field name is allowed as it may be used by add-ons.
|
||||||
&& self
|
!name.as_ref().is_empty()
|
||||||
.fields
|
&& !special_fields.contains(&name.as_ref())
|
||||||
.iter()
|
&& self.fields.iter().all(|field| field.name != name.as_ref())
|
||||||
.map(|field| &field.name)
|
|
||||||
.all(|field_name| field_name != name.as_ref())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue