diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-03 15:35:19 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-03-03 15:35:19 +0100 |
commit | f9a52b2784565e9d938ed1c8a397e2764b25fe20 (patch) | |
tree | 36d8d10f79aece5e9537be2ecc1341b14e2026a9 /README.rst | |
parent | a407cd477bc50582994f21bc8c4f9fc961e177fd (diff) | |
download | askama-f9a52b2784565e9d938ed1c8a397e2764b25fe20.tar.gz askama-f9a52b2784565e9d938ed1c8a397e2764b25fe20.tar.bz2 askama-f9a52b2784565e9d938ed1c8a397e2764b25fe20.zip |
Add debugging and troubleshooting section to README
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -94,7 +94,35 @@ 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: + + +Debugging and troubleshooting +----------------------------- + +You can debug your the parse tree for a template and the generated code by +changing the ``template`` attribute item list for the template struct: + +.. code-block:: rust + + #[derive(Template)] + #[template(path = "hello.html", print = "all")] + struct HelloTemplate<'a> { ... } + +The ``print`` key can take one of four values: + +* ``none`` (the default value) +* ``ast`` (print the parse tree) +* ``code`` (print the generated code) +* ``all`` (print both parse tree and code) + +The parse tree looks like this for the example template: + +.. code-block:: + + [Lit("", "Hello,", " "), Expr(WS(false, false), Var("name")), + Lit("", "!", "\n")] + +The generated code looks like this: .. code-block:: rust |