liquid_core/parser/
text.rs

1use std::io::Write;
2
3use crate::error::{Result, ResultLiquidReplaceExt};
4use crate::runtime::Renderable;
5use crate::runtime::Runtime;
6
7/// A raw template expression.
8#[derive(Clone, Debug, Eq, PartialEq)]
9pub(crate) struct Text {
10    text: String,
11}
12
13impl Text {
14    /// Create a raw template expression.
15    pub(crate) fn new<S: Into<String>>(text: S) -> Text {
16        Text { text: text.into() }
17    }
18}
19
20impl Renderable for Text {
21    fn render_to(&self, writer: &mut dyn Write, _runtime: &dyn Runtime) -> Result<()> {
22        write!(writer, "{}", &self.text).replace("Failed to render")?;
23        Ok(())
24    }
25}