diff --git a/Cargo.toml b/Cargo.toml index f4709747d..11a67cc61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,12 +18,16 @@ appveyor = { repository = "cobalt-org/liquid-rust" } [[bin]] name = "liquid-dbg" -required-features = ["cli"] +required-features = ["cli", "serde"] test = false doctest = false bench = false doc = false +[[test]] +name = "liquid" +required-features = ["serde"] + [features] default = ["extra-filters"] cli = ["clap", "error-chain", "serde_yaml"] @@ -37,9 +41,8 @@ chrono = "0.3" unicode-segmentation = "1.1" itertools = "0.6.0" url = "1.4" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", optional = true, features = ["derive"] } clap = { version = "2.22.0", optional = true } error-chain = { version = "0.10.0", optional = true } serde_yaml = { version = "0.7", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 8fad3a410..77b357080 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,10 +39,9 @@ extern crate url; #[macro_use] extern crate lazy_static; - -extern crate serde; +#[cfg(feature = "serde")] #[macro_use] -extern crate serde_derive; +extern crate serde; use std::collections::HashMap; use lexer::Element; diff --git a/src/value.rs b/src/value.rs index 6d6780f36..ce1c0cf3c 100644 --- a/src/value.rs +++ b/src/value.rs @@ -8,8 +8,8 @@ use token::Token::*; /// An enum to represent different value types #[derive(Clone, Debug)] -#[derive(Serialize, Deserialize)] -#[serde(untagged)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum Value { Num(f32), Bool(bool), diff --git a/tests/liquid.rs b/tests/liquid.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tests/liquid.rs @@ -0,0 +1 @@ +