Comments (7)
Just put the impl
for serde_json::Value
in a separate module, like serde.rs
. In lib.rs
do a conditional import:
#[cfg(feature = "json")]
mod serde;
Adding serde_json
as optional feature in Cargo.toml
:
[dependencies]
# ...all the other deps
serde_json = { version = "1.0", optional = true }
[features]
default = []
# Implements `Content` for `serde_json::Value`
json = ["serde_json"]
That way enabling the json
feature will build Ramhorns with serde_json
and the module that contains the trait impl
.
from ramhorns.
I will try implementing Content trait for serde_json::Value
from ramhorns.
Ramhorns supports HashMap
s and BTreeMap
s so you can construct arbitrary dynamic structures that way. To work with serde_json::Value
directly the Content
trait would need to be implemented for it, we could add it to the ramhorns crate via a feature with optional serde_json
dependency.
This should be a good first issue if anyone wants to drop a PR, I might not have time to tackle this within the next week or two.
from ramhorns.
If serde_json
is to be an optional dependency, then how shall I organize the added support for serde_json::Value
? I'm somewhat new to Rust, so providing as much detail as possible would be appreciated.
from ramhorns.
I think I might be hitting this as well.
But to make sure - there is no alternative means of using arbitary json (even if say, converted to some string type) with a template and ramhorns today, correct? I've been unsuccessful anyways.
If that is the case then I'm a huge 👍 on this feature request and I would be curious to know if there has been any progress on the feature!
from ramhorns.
@eeyun don't think there has been, happy to accept a PR.
from ramhorns.
Cool I just wanted to make sure. It would be a great feature. I may try to get something together for it but a bit underwater currently. Thanks for maintaining the project either way!
from ramhorns.
Related Issues (20)
- Internationalization (i18n) HOT 4
- Compatibility with serde HOT 1
- Feature: impl std::error::Error for ramhorns::Error HOT 1
- Partials and Handlebars semantics
- 1.0 Roadmap HOT 3
- Lambdas sections? HOT 6
- (macro-hygiene) ramhorn derive codegen clashes with syn::Result HOT 2
- Generic type bounds are not handled HOT 3
- derive Content on enums
- Is it possible to name elements of a Vec<String>? HOT 2
- Add support for dot notation HOT 4
- Support for custom file extensions
- Quick Question: Setting Pulldown-Cmark Options
- beef 0.5 HOT 1
- Recursive partials cause stack overflow HOT 1
- Confusing result when missing partial files HOT 3
- Comparison with Tera and Askama HOT 1
- benchmark with fxhash HOT 2
- BTreeMap vs HashMap HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ramhorns.