Trangar / periodic_table

Library that provides a list of elements in the periodic table
3 stars 1 forks source link

Switch template engine to Askama #6

Closed noirotm closed 5 years ago

noirotm commented 5 years ago

This commit has the benefit of improving type safety, as well as reducing code size.

It has been a bit challenging to use Askama, as the documentation isn't that great compared to handlebars, especially regarding custom filters. For example, surprisingly, {{ a|b }} works, while {{ a | b }} refuses to compile. It is also a little bit more rigid as templates need to be placed in a dedicated templates directory.

In the end it works fine :smile:

VictorKoenders commented 5 years ago

reducing code size. 🎉

as the documentation isn't that great compared to handlebars This is something I also ran into when I began, but I personally don't see how to fix this

VictorKoenders commented 5 years ago

I wish publish this to crates.io soon-ish, probably within 24 hours

VictorKoenders commented 5 years ago

Released 0.2.0 🎉

Also apparently cargo doesn't like it when you modify the lib.rs during a deploy:

error: failed to verify package tarball

Caused by:
  Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR.
Added: /home/trangar/development/rust/periodic_table/target/package/periodic_table-0.2.0/src/lib.rs

To proceed despite this, pass the `--no-verify` flag.
noirotm commented 5 years ago

cargo doesn't like it when you modify the lib.rs during a deploy

This could be fixed by following https://doc.rust-lang.org/cargo/reference/build-scripts.html#case-study-code-generation.

Basically, we keep a simple lib.rs which reexports a module written in OUT_DIR. Seems the cleanest thing to do. I believe Askama itself writes the compiled template in that directory.

Gonna try this today.

VictorKoenders commented 5 years ago

Yes, I think so too. I have opened an issue for this: #7