diff --git a/rslib/src/notetype/render.rs b/rslib/src/notetype/render.rs index e739ce9d7..9c80c7fbf 100644 --- a/rslib/src/notetype/render.rs +++ b/rslib/src/notetype/render.rs @@ -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"); diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 2144678e0..7338f2684 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -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()) {