diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-15 21:03:32 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-02-15 21:03:32 +0100 |
commit | 193de3d264e42bd331b43083085f1ca21af72d39 (patch) | |
tree | 097578af23795a0486752e4fb703cc93e3acb378 /README.rst | |
parent | 72241bcc422fa9c6bd212f64f3024876cda3e2d7 (diff) | |
download | askama-193de3d264e42bd331b43083085f1ca21af72d39.tar.gz askama-193de3d264e42bd331b43083085f1ca21af72d39.tar.bz2 askama-193de3d264e42bd331b43083085f1ca21af72d39.zip |
Show generated code in README
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -95,6 +95,21 @@ In any Rust file inside your crate, add the following: } You should now be able to compile and run this code. +Askama should generate Rust code like below: + +.. code-block:: rust + + #[allow(dead_code, non_camel_case_types)] + type TemplateFromhello2ehtml<'a> = HelloTemplate<'a>; + impl<'a> askama::Template for HelloTemplate<'a> { + fn render_to(&self, writer: &mut std::fmt::Write) { + writer.write_str("Hello,").unwrap(); + writer.write_str(" ").unwrap(); + writer.write_fmt(format_args!("{}", self.name)).unwrap(); + writer.write_str("!").unwrap(); + writer.write_str("\n").unwrap(); + } + } Review the `test cases`_ for more examples. |