filter_template

Function filter_template 

Source
pub fn filter_template(
    src: &str,
    fragment: &str,
) -> Result<String, ErrorWithLine>
Expand description

Process the template and return all parts for the given fragment

To obtain the base template use an empty string for the fragment.

let source = concat!(
    "<body>\n",
    "  {% fragment item %}\n",
    "    <div>{{ item }}</div>\n",
    "  {% endfragment %}\n",
    "<body>\n",
);

assert_eq!(
    filter_template(source, "").unwrap(),
    concat!(
        "<body>\n",
        "    <div>{{ item }}</div>\n",
        "<body>\n",
    ),
);

assert_eq!(
    filter_template(source, "item").unwrap(),
    "    <div>{{ item }}</div>\n",
);