Type Alias ExternalFormatter

Source
pub type ExternalFormatter = dyn Fn(&str, String, &Configuration) -> Result<Option<String>>;
Expand description

A callback that will be called when encountering tagged templates.

It is up to the caller to decide if a certain tagged template should be formatted by the external formatter.

Examples:

const styles = css`color: red;`;

const markup = html`<html>
  <body>
    <h1>Hello!<h1>
  </body>
</html>`;

const query = sql`
SELECT
  *
FROM
  users
WHERE
  active IS TRUE;

External formatter should return None if it doesn’t understand given language, in such cases the templates will be left as they are.

Only templates with no interpolation are supported.