bheisler / TinyTemplate

A small, lightweight template engine
Apache License 2.0
198 stars 49 forks source link

Drop `serde_json` #1

Open bheisler opened 5 years ago

bheisler commented 5 years ago

TinyTemplate converts the context structure to serde_json::Value internally so that it can look up values by string keys. This introduces a dependency on serde_json even though we don't really do any JSON serialization. If TinyTemplate had its own version of Value which could be constructed by a custom serde serializer, we could drop serde_json and only depend on serde.

This is not a high priority for Criterion.rs (which depends on serde_json anyway). I would be happy to accept a pull request though.

Legend-of-iPhoenix commented 3 years ago

Here's my solution for this from a similar project- you're welcome to use it of course: https://github.com/Legend-of-iPhoenix/microtemplate/blob/1dff2cc818ed144ef74f3062ecea7bf7d4c7bb8d/microtemplate_derive/src/lib.rs

bheisler commented 3 years ago

Hello! I think the benefits of that approach would be minimal, honestly. The main goal for this ticket is to reduce clean-compile time and code bloat. This would require a new proc-macro and all of the associated machinery so the dependency tree isn't that much smaller (and the macro itself is less likely to already be in the user's dependency tree than serde-derive), and it adds a new derive that users need to apply and a new data model (which would be an API-breaking change in a couple of ways). Thanks for your interest, but I don't think I want to move forward with that approach.