aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Tomas <maklins08@gmail.com>2018-11-07 10:28:56 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-11-07 20:13:11 +0100
commit93884b7fbeb6c403c166e3f956edd44421dbcf9b (patch)
tree539b2fb745141645c413bdb75be25e6083ca8dca
parent471654dd94e862721384a89d61c47697d536648d (diff)
downloadaskama-93884b7fbeb6c403c166e3f956edd44421dbcf9b.tar.gz
askama-93884b7fbeb6c403c166e3f956edd44421dbcf9b.tar.bz2
askama-93884b7fbeb6c403c166e3f956edd44421dbcf9b.zip
Update generated code example
-rw-r--r--README.md22
1 files changed, 13 insertions, 9 deletions
diff --git a/README.md b/README.md
index 8e51642..788a25e 100644
--- a/README.md
+++ b/README.md
@@ -154,18 +154,22 @@ Lit("", "!", "\n")]
The generated code looks like this:
```rust
-impl< 'a > ::askama::Template for HelloTemplate< 'a > {
- fn render_into(&self, writer: &mut ::std::fmt::Write) -> Result<(), ::std::fmt::Error> {
- writer.write_str("Hello,")?;
- writer.write_str(" ")?;
- writer.write_fmt(format_args!("{}", self.name))?;
- writer.write_str("!")?;
+impl < 'a > ::askama::Template for HelloTemplate< 'a > {
+ fn render_into(&self, writer: &mut ::std::fmt::Write) -> ::askama::Result<()> {
+ write!(
+ writer,
+ "Hello, {}!",
+ &::askama::MarkupDisplay::from(&self.name),
+ )?;
Ok(())
}
+ fn extension() -> Option<&'static str> {
+ Some("html")
+ }
}
-impl< 'a > ::std::fmt::Display for HelloTemplate< 'a > {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
- self.render_into(f)
+impl < 'a > ::std::fmt::Display for HelloTemplate< 'a > {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ ::askama::Template::render_into(self, f).map_err(|_| ::std::fmt::Error {})
}
}
```