Function eyeliner::inline [] [src]

pub fn inline(
    html: &str,
    css: Option<&str>,
    options: Option<Options>,
    settings: Option<Settings>
) -> String

Returns a string of HTML with CSS inlined.

Arguments

Remarks

Convenient function to inline HTML and CSS the same way as Juice.

Examples

use eyeliner::inline;

  let html = r#"
    <!DOCTYPE html>
    <html>
      <head>
        <title>Test</title>
      </head>
      <body>
        <h1>Hello, world!</h1>
        <p>I <span class="red">love</span> Rust!</p>
      </body>
    </html>
  "#;

  let css = r#"
    .red {
      color: red;
    }
  "#;

  let fixture = r#"
    <!DOCTYPE html>
    <html>
      <head>
        <title>Test</title>
      </head>
      <body>
        <h1>Hello, world!</h1>
        <p>I <span class="red" style="color: red;">love</span> Rust!</p>
      </body>
    </html>
  "#;

  assert_eq!(
    inline(fixture, None, None, None), // Just used to format the HTML the same way
    inline(html, Some(css), None, None),
  );