diff options
| author | 2024-01-09 17:24:11 +0100 | |
|---|---|---|
| committer | 2024-01-09 21:23:47 +0100 | |
| commit | 50c64bc8650574d1e9243a50477eb7dbd36e36c4 (patch) | |
| tree | 6d8d9060fe76f1994062e2c22559501ae66cfd48 /testing/tests | |
| parent | b8697ba20205c01ac43da4e3054a2d3f3be007b9 (diff) | |
| download | askama-50c64bc8650574d1e9243a50477eb7dbd36e36c4.tar.gz askama-50c64bc8650574d1e9243a50477eb7dbd36e36c4.tar.bz2 askama-50c64bc8650574d1e9243a50477eb7dbd36e36c4.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | testing/tests/markdown.rs | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/testing/tests/markdown.rs b/testing/tests/markdown.rs index 75163c9..04c9ec9 100644 --- a/testing/tests/markdown.rs +++ b/testing/tests/markdown.rs @@ -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" +    ) +} | 
