Update for the latest nom and make serde an optional dep.
This commit is contained in:
parent
aa3ed99fca
commit
a9a83d1b4a
@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
json-integration = []
|
||||
json-integration = ["serde", "serde_json"]
|
||||
|
||||
[lib]
|
||||
name = "duster"
|
||||
@ -19,5 +19,5 @@ required-features = ["json-integration"]
|
||||
|
||||
[dependencies]
|
||||
nom = { git = "https://github.com/tomalexander/nom.git", branch = "take_until_parser_matches" }
|
||||
serde = "1.0.106"
|
||||
serde_json = "1.0.51"
|
||||
serde = { version = "1.0.106", optional = true }
|
||||
serde_json = { version = "1.0.51", optional = true }
|
||||
|
6
src/integrations/json.rs
Normal file
6
src/integrations/json.rs
Normal file
@ -0,0 +1,6 @@
|
||||
//! This file contains an integration for duster that implements
|
||||
//! support for using serde_json values for the render context. This
|
||||
//! is in its own separate file to avoid requiring serde as a
|
||||
//! dependency since ContextElement can be implemented for any
|
||||
//! type. Disable the json-integration feature to avoid compiling this
|
||||
//! file and adding the serde and serde_json dependencies.
|
@ -807,7 +807,10 @@ mod tests {
|
||||
assert_eq!(super::special("{~rb}"), Ok(("", Special::RightCurlyBrace)));
|
||||
assert_eq!(
|
||||
super::special("{~zzz}"),
|
||||
Err(Error(("zzz}", ErrorKind::Tag)))
|
||||
Err(Error(nom::error::Error {
|
||||
input: "zzz}",
|
||||
code: ErrorKind::Tag
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@ -824,10 +827,10 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
super::special("{! this is a comment without a close"),
|
||||
Err(Error((
|
||||
"{! this is a comment without a close",
|
||||
ErrorKind::Tag
|
||||
)))
|
||||
Err(Error(nom::error::Error {
|
||||
input: "{! this is a comment without a close",
|
||||
code: ErrorKind::Tag
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@ -861,7 +864,10 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
super::span("{~lb}"),
|
||||
Err(Error(("{~lb}", ErrorKind::Verify)))
|
||||
Err(Error(nom::error::Error {
|
||||
input: "{~lb}",
|
||||
code: ErrorKind::Verify
|
||||
}))
|
||||
);
|
||||
assert_eq!(
|
||||
super::body("this is \t \n\n \t \n \t multiline text\n {foo}"),
|
||||
@ -911,7 +917,10 @@ mod tests {
|
||||
fn test_section_mismatched_paths() {
|
||||
assert_eq!(
|
||||
super::dust_tag("{#foo.bar}{/baz}"),
|
||||
Err(Error(("{#foo.bar}{/baz}", ErrorKind::Tag)))
|
||||
Err(Error(nom::error::Error {
|
||||
input: "{#foo.bar}{/baz}",
|
||||
code: ErrorKind::Tag
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@ -1539,7 +1548,7 @@ mod tests {
|
||||
{.}
|
||||
{/names}"
|
||||
),
|
||||
Ok::<_, nom::Err<(&str, ErrorKind)>>((
|
||||
Ok::<_, nom::Err<nom::error::Error<&str>>>((
|
||||
"",
|
||||
Template {
|
||||
contents: Body {
|
||||
@ -1613,7 +1622,7 @@ mod tests {
|
||||
super::template(
|
||||
r#"{#level3.level4}{>partialtwo v1="b" v2="b" v3="b" v4="b" v5="b" /}{/level3.level4}"#
|
||||
),
|
||||
Ok::<_, nom::Err<(&str, ErrorKind)>>((
|
||||
Ok::<_, nom::Err<nom::error::Error<&str>>>((
|
||||
"",
|
||||
Template {
|
||||
contents: Body {
|
||||
|
Loading…
Reference in New Issue
Block a user