Uploaded image for project: 'Click'
  1. Click
  2. CLK-396

Chained HtmlStringBuffer.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5 M1
    • 1.5 M2
    • None
    • None

    Description

      #1. Please add a chaining based HtmlStringBuffer utility class.
      I know that method chaining is pretty bad practice for many cases, and when available it's always totally misused (I revied myself allot of such code), but I think in the case of HtmlStringBuffer it would be an improvement and would make the rendering code (that is ugly indepenent of language due to HTML ) look a little bit nicer:
      Unchained:
      ----------------------------
      buffer.elementStart("button");
      buffer.appendAttribute("id", "theId");
      buffer.appendAttribute("type", "button");
      buffer.closeTag();
      buffer.append("Button Text");
      buffer.elementEnd("button);
      -----------------------------

      chained:
      -----------------------------
      buffer.elementStart("button")
      .appendAttribute("id", "theId")
      .appendAttribute("type", "button")
      .closeTag()
      .append("Button Text");
      buffer.elementEnd("button);
      -----------------------------

      or even (to simulate the HTML nesting):
      -----------------------------
      buffer.elementStart("button").appendAttribute("id", "theId").appendAttribute("type", "button") .closeTag()
      .append("Button Text");
      buffer.elementEnd("button);
      -----------------------------

      For more HTML elements and more nesting, the advantage is even more visible.

      #2. If it's possible, please shorten the syntax if possible (e.g. I think "appendAttribute()" is just too long).

      Attachments

        Activity

          People

            medgar Malcolm Edgar
            dkyriakis Demetrios Kyriakis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: