mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 13:30:59 +00:00
Make the markdown
filter compatible with String
This commit solves issue #719. This is done by making the markdown filter borrow the string and simplifying the filter to accept `&str` instead of `AsRef<str>` Add test for the markdown filter using as input Revert markdown filter changes Revert unnecessary changes Improve test_markdown_owned_string test Use cargo fmt
This commit is contained in:
parent
b8697ba202
commit
50c64bc865
@ -1200,7 +1200,7 @@ impl<'a> Generator<'a> {
|
||||
};
|
||||
|
||||
buf.write(&format!(
|
||||
"::askama::filters::markdown({}, ",
|
||||
"::askama::filters::markdown({}, &",
|
||||
self.input.escaper
|
||||
));
|
||||
self.visit_expr(buf, md)?;
|
||||
|
@ -70,3 +70,21 @@ before\
|
||||
after",
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = "{{content|markdown}}", ext = "html")]
|
||||
struct MarkdownStringTemplate {
|
||||
content: String,
|
||||
}
|
||||
|
||||
// Tests if the markdown filter accepts String
|
||||
#[test]
|
||||
fn test_markdown_owned_string() {
|
||||
let template = MarkdownStringTemplate {
|
||||
content: "The markdown filter _indeed_ works with __String__".into(),
|
||||
};
|
||||
assert_eq!(
|
||||
template.render().unwrap(),
|
||||
"<p>The markdown filter <em>indeed</em> works with <strong>String</strong></p>\n"
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user