Add support for literal string blocks.
This commit is contained in:
parent
533ea96d4f
commit
b73561caf9
@ -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…
x
Reference in New Issue
Block a user