rshtml_core 0.1.0

RsHtml: A Template Engine for Seamless HTML and Rust Integration.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::compiler::Compiler;
use anyhow::{Result, anyhow};
use proc_macro2::TokenStream;
use std::str::FromStr;

pub struct RustExprParenCompiler;

impl RustExprParenCompiler {
    pub fn compile(compiler: &mut Compiler, expr: &str, is_escaped: &bool) -> Result<TokenStream> {
        let expr_ts = TokenStream::from_str(expr).map_err(|err| anyhow!("Lex Error: {}", err))?;

        Ok(compiler.escape_or_raw(expr_ts, is_escaped))
    }
}