supplier/html-splitter/src/main/java/io/knotx/fragments/supplier/html/splitter/HtmlFragmentSplitter.java
/**
   * Splits a template (markup) into list of fragments (see {@link Fragment}).
   *
   * @param html - a string containing the template content which will be split.
   * @return list of fragments (see {@link Fragment}).
   */
Splits a template (markup) into list of fragments .
@param html - a string containing the template content which will be split.
@return list of fragments .
Splits a template ( markup ) into list of fragments . @param html - a string containing the template content which will be split . @return list of fragments .
List<Fragment> split(String html) {
    LOGGER.trace("Splitting HTML: ", html);
    List<Fragment> fragments = new ArrayList<>();
    if (StringUtils.isNotBlank(html)) {
      Matcher matcher = DYNAMIC_FRAGMENT_PATTERN.matcher(html);
      int idx = 0;
      while (matcher.find()) {
        MatchResult matchResult = matcher.toMatchResult();
        if (idx < matchResult.start()) {
          fragments.add(toStatic(html, idx, matchResult.start()));
        }
        fragments.add(
            toDynamic(matcher.group("type"), matcher.group("attributes"), matcher.group("body")));
        idx = matchResult.end();
      }
      if (idx < html.length()) {
        fragments.add(toStatic(html, idx, html.length()));
      }
    }
    return fragments;
  }
List < Fragment > split ( String html ) { LOGGER . trace ( "Splitting HTML: " , html ) ; List < Fragment > fragments = new ArrayList < > ( ) ; if ( StringUtils . isNotBlank ( html ) ) { Matcher matcher = DYNAMIC_FRAGMENT_PATTERN . matcher ( html ) ; int idx = 0 ; while ( matcher . find ( ) ) { MatchResult matchResult = matcher . toMatchResult ( ) ; if ( idx < matchResult . start ( ) ) { fragments . add ( toStatic ( html , idx , matchResult . start ( ) ) ) ; } fragments . add ( toDynamic ( matcher . group ( "type" ) , matcher . group ( "attributes" ) , matcher . group ( "body" ) ) ) ; idx = matchResult . end ( ) ; } if ( idx < html . length ( ) ) { fragments . add ( toStatic ( html , idx , html . length ( ) ) ) ; } } return fragments ; }
Splits a template (markup) into list of fragments (see {@link Fragment}).
Splits a template ( markup ) into list of fragments ( see { @link Fragment } ) .