pub fn hairy_compile_html<'b>(
    reader: &'b str,
    filename: &'b str,
    inline_overrides: Option<&DecodedValue<'b>>,
    extra_line_no: u32
) -> Result<BytecodeVec, String>
Expand description

The ‘easy’ interface if you just want to quickly use a HTML template, with auto escaping of the input, and returning a nicely formatted error that can be presented to the user. For more options, see the hairy_compile function.

To evaluate, use hairy_eval_html, so the proper escaper is used.

Note that although hairy_compile_html and hairy_eval_html are easier to use, they are somewhat slower. For top performance please use other functions.

The inline_overrides argument overrides the inline key-value pairs that can be specified on the top of a template. These keys can contain alphanumeric characters, _, and $. The values should be valid expry expressions (JSON is a valid expry). These values are compiled using the inline_overrides as value, so the inlines and defaults can depend on a (sub)value of compiled (so derived inlines and defaults can be generated).


use hairy::*;
use expry::*;
use std::io::Write;
let template = r#"foobar = {{=foovar .. barvar}}"#;
let result = hairy_compile_html(template, "test.tpl", None, 0);
match result {
  Ok(parsed) => {
    let value = value!({
      "foovar": "foo",
      "barvar": "bar",
    match hairy_eval_html(parsed.to_ref(), value.to_ref()) {
      Ok(output) => { std::io::stdout().write_all(&output); },
      Err(err) => { eprintln!("{}", err); },
  Err(err) => {
    eprintln!("{}", err);