Function attach

  • Attach a given tag to the current context. When you attach a tag, this tag will be the "root" for any tag created without a parent.

    • If there is not attached tag, it will be attached
    • If there is already a tag attached, it will store the previous tag and will set the new tag as the root. After finishing using the tag as the root, you can call @detach and return to the previous root tag.

    This is used to remove clutter and reduntancies when creating hobo docs. Like this:

    Parameters

    Returns void

    Example

    Simple example with only 1 attach

    const parent = doc();
    attach(parent);

    div();
    p();

    The div and p tags will be automatically added as child of parentDiv

    Example

    Example attaching and detaching

    const parent = doc();
    attach(parent);

    div();
    p();
    let d1 = div();
    attach(d1);
    // All the p tags will be added to `d1`
    p();
    p();
    p();
    // remember to call detach when you want to go back to the previous root tag
    detach();

Generated using TypeDoc