Merge branch 'literal_string_block' into render

master
Tom Alexander 4 years ago
commit 6c89f7c59a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -0,0 +1,5 @@
{`
This block is supposed
to preserve {name} all
newlines, whitespace, and braces
`}

@ -27,6 +27,7 @@ use nom::IResult;
pub enum DustTag<'a> {
DTSpecial(Special),
DTComment(Comment<'a>),
DTLiteralStringBlock(&'a str),
DTReference(Reference<'a>),
DTSection(Container<'a>),
DTExists(Container<'a>),
@ -211,6 +212,7 @@ fn dust_tag(i: &str) -> IResult<&str, DustTag> {
alt((
map(special, DustTag::DTSpecial),
map(comment, DustTag::DTComment),
map(literal_string_block, DustTag::DTLiteralStringBlock),
map(reference, DustTag::DTReference),
conditional("{#", DustTag::DTSection),
conditional("{?", DustTag::DTExists),
@ -634,6 +636,10 @@ fn ignore_new_line_leading_whitespace(i: &str) -> IResult<&str, IgnoredWhitespac
)(i)
}
fn literal_string_block(i: &str) -> IResult<&str, &str> {
delimited(tag("{`"), take_until("`}"), tag("`}"))(i)
}
/// Any text that is not a Dust element or ignored whitespace
fn span(i: &str) -> IResult<&str, Span> {
let (remaining, line) = verify(

@ -63,6 +63,7 @@ fn extract_inline_partials_from_tag<'a, 'b>(
match tag {
DustTag::DTComment(..) => (),
DustTag::DTSpecial(..) => (),
DustTag::DTLiteralStringBlock(..) => (),
DustTag::DTReference(..) => (),
DustTag::DTSection(container) => {
match &container.contents {

@ -144,6 +144,7 @@ impl<'a> DustRenderer<'a> {
}
.to_owned())
}
DustTag::DTLiteralStringBlock(literal) => return Ok((*literal).to_owned()),
DustTag::DTReference(reference) => {
let val = walk_path(breadcrumbs, &reference.path.keys);
match val {

Loading…
Cancel
Save