groovy

New MarkupBuilder options

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

I made some additional options and fixed a bug in the MarkupBuilder and would like to submit the code back to Groovy.

1. Added an HTML mode
example:
p("this is a node") {
b("this is bolded text")
}

The above code for xml is invalid, but is valid for html. Therefore, the html mode changes the MarkupBuilder to allow the looser html style. The default constructors default to html mode = false

2. Fixed empty element completion bug
example:
br()

The above code was returning <br instead of <br />. The fix was to set the nodeIsEmpty flag back to true in the nodeCompleted method. br(" ") still prints out <br> </br>

3. Added a double quote option. This flag allows attributes to print out with double quotes. The default constructors default to doubleQuote = false
example: <element attr="1" /> or <element attr='1' />

4. Added a newline for attribute flag. This flag allows attributes to print out on new lines. The default constructors default to attributeNewLine = false
example:

<element attr1='1'
attr2='2'>

  1. GROOVY-1520.patch
    09/Dec/06 10:27 AM
    10 kB
    Peter Ledbrook
  2. markupbuilder.tar
    05/Oct/06 5:16 PM
    30 kB
    Tony Lauro

Activity

Hide
Peter Ledbrook added a comment -

This patch can be applied to HEAD (as of 9 Dec, 2006). It incorporates the fix provided with GROOVY-1091 that clears up the problem with unclosed empty elements, and it also implements the option to emit double quotes for attribute values. The test case has also been updated.

If the patch is applied, both GROOVY-1091 and GROOVY-1490 can be closed.

I'm not sure whether the "HTML" (AKA mixed content) mode makes much sense, since you still can't emit with arbitrary mixed content as one can with StreamingMarkupBuilder.

Show
Peter Ledbrook added a comment - This patch can be applied to HEAD (as of 9 Dec, 2006). It incorporates the fix provided with GROOVY-1091 that clears up the problem with unclosed empty elements, and it also implements the option to emit double quotes for attribute values. The test case has also been updated. If the patch is applied, both GROOVY-1091 and GROOVY-1490 can be closed. I'm not sure whether the "HTML" (AKA mixed content) mode makes much sense, since you still can't emit with arbitrary mixed content as one can with StreamingMarkupBuilder.
Hide
John Wilson added a comment -

Applied Patch - Thaks to Peter for the patch and, especially, for the test cases

Show
John Wilson added a comment - Applied Patch - Thaks to Peter for the patch and, especially, for the test cases

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: