mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Fix full template render choking on empty fields
This commit is contained in:
parent
dc56a2ca7d
commit
5506f9bf2d
2 changed files with 14 additions and 10 deletions
|
@ -225,7 +225,7 @@ mod test {
|
|||
|
||||
// should work even if unknown filters are encountered
|
||||
let mut tmpl = nt.templates[0].clone();
|
||||
tmpl.config.q_format = "{{some_filter:Front}}".into();
|
||||
tmpl.config.q_format = "{{some_filter:Front}}{{another_filter:}}".into();
|
||||
let out = col.render_uncommitted_card(&mut note, &nt.templates[0], 0, false, false)?;
|
||||
assert_eq!(&out.question(), "front");
|
||||
|
||||
|
|
|
@ -446,15 +446,19 @@ fn render_into(
|
|||
}
|
||||
}
|
||||
Replacement { key, filters } => {
|
||||
if context.partial_for_python && key.is_empty() && !filters.is_empty() {
|
||||
// if a filter is provided, we accept an empty field name to
|
||||
// mean 'pass an empty string to the filter, and it will add
|
||||
// its own text'
|
||||
rendered_nodes.push(RenderedNode::Replacement {
|
||||
field_name: "".to_string(),
|
||||
current_text: "".to_string(),
|
||||
filters: filters.clone(),
|
||||
});
|
||||
if key.is_empty() && !filters.is_empty() {
|
||||
if context.partial_for_python {
|
||||
// if a filter is provided, we accept an empty field name to
|
||||
// mean 'pass an empty string to the filter, and it will add
|
||||
// its own text'
|
||||
rendered_nodes.push(RenderedNode::Replacement {
|
||||
field_name: "".to_string(),
|
||||
current_text: "".to_string(),
|
||||
filters: filters.clone(),
|
||||
});
|
||||
} else {
|
||||
// nothing to do
|
||||
}
|
||||
} else {
|
||||
// apply built in filters if field exists
|
||||
let (text, remaining_filters) = match context.fields.get(key.as_str()) {
|
||||
|
|
Loading…
Reference in a new issue