split_templates

Function split_templates 

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

Split the template into all fragments available

The base template is included as the fragment "".

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

assert_eq!(
    templates[""],
    concat!(
        "<body>\n",
        "    <div>{{ item }}</div>\n",
        "<body>\n",
    ),
);

assert_eq!(
    templates["item"],
    "    <div>{{ item }}</div>\n",
);