Skip to main content

convert_tpl_to_string_lit

Function convert_tpl_to_string_lit 

pub fn convert_tpl_to_string_lit(tpl: &Tpl) -> Option<Lit>
Expand description

Helper function to convert a Tpl to a string literal

§Arguments

  • tpl - The template literal to convert

§Returns

  • Option<Lit> - The string literal if the template is simple (no interpolations)
  • None - If the template is not simple (has interpolations)

§Example

Input: Tpl { exprs: [], quasis: [TplElement { cooked: Some("hello"), raw: "hello" }] }
Output: Some(Lit::Str("hello"))