@Override
  public void startContainerLayout(C container, M metawidget) {

    super.startContainerLayout(container, metawidget);

    State<C> state = getState(container, metawidget);
    state.currentSection = null;
    state.currentSectionWidget = null;
  }
  @Override
  public void layoutWidget(
      W widget, String elementName, Map<String, String> attributes, C container, M metawidget) {

    // Stay where we are?
    //
    // Note: Ignore empty stubs. Do not create a new section in case it ends up being empty

    String section = stripSection(attributes);
    State<C> state = getState(container, metawidget);

    if (isEmptyStub(widget) || section == null || section.equals(state.currentSection)) {
      if (state.currentSectionWidget == null) {
        super.layoutWidget(widget, elementName, attributes, container, metawidget);
      } else {
        super.layoutWidget(widget, elementName, attributes, state.currentSectionWidget, metawidget);
      }

      return;
    }

    // End current section

    C previousSectionWidget = state.currentSectionWidget;

    if (state.currentSectionWidget != null) {
      super.endContainerLayout(state.currentSectionWidget, metawidget);
    }

    state.currentSection = section;
    state.currentSectionWidget = null;

    // No new section?

    if ("".equals(section)) {
      super.layoutWidget(widget, elementName, attributes, container, metawidget);
      return;
    }

    // Start new section

    state.currentSectionWidget =
        createSectionWidget(previousSectionWidget, attributes, container, metawidget);
    super.startContainerLayout(state.currentSectionWidget, metawidget);

    // Add component to new section

    super.layoutWidget(widget, elementName, attributes, state.currentSectionWidget, metawidget);
  }
  @Override
  public void endContainerLayout(C container, M metawidget) {

    // End hanging layouts

    State<C> state = getState(container, metawidget);

    if (state.currentSectionWidget != null) {
      super.endContainerLayout(state.currentSectionWidget, metawidget);
    }

    super.endContainerLayout(container, metawidget);
    state.currentSection = null;
    state.currentSectionWidget = null;
  }