Function transform

  • Transform HTML

    Uses posthtml for transformation. See: posthtml plugins for examples.

    Parameters

    • filePath: string
    • plugin: Plugin<unknown> | Plugin<unknown>[]

    Returns Promise<void>

    Example

    the before option is to insert HTML before the first tag specified -- link in this case.

    import { html } from 'ember-apply';

    await html.transform(filePath, (tree) => {
    tree.match(({ tag: 'head' }, 'head') => {
    if (node.content) {
    node.content.unshift({ tag: 'noscript', content: 'Please enable javascript' });
    }

    return node;
    });
    });

    Example borrowed from posthtml-noscript

Generated using TypeDoc