You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/02/05 11:36:41 UTC

[jira] [Commented] (GROOVY-8040) Markup Templates: improve pretty printing

    [ https://issues.apache.org/jira/browse/GROOVY-8040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15853208#comment-15853208 ] 

Paul King commented on GROOVY-8040:
-----------------------------------

A directly runnable version of above example:
{code}
import groovy.text.markup.*
def config = new TemplateConfiguration(autoIndent: true, autoNewLine: true)
def engine = new MarkupTemplateEngine(config)
def template = engine.createTemplate('''
html {
  head {    
    title('The title')
    meta(name: 'title', content: 'The title')
    meta(name: 'description', content: 'The description')
  }
}
''')
def sw = new StringWriter()
template.make([:]).writeTo(sw)
println sw
{code}

> Markup Templates: improve pretty printing
> -----------------------------------------
>
>                 Key: GROOVY-8040
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8040
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Templating
>    Affects Versions: 2.4.7
>            Reporter: Sinuhé
>            Priority: Minor
>
> When I execute a template such as:
> {code}
> html {
>   head {	
>     title('The title')
>     meta(name: 'title', content: 'The title')
>     meta(name: 'description', content: 'The description')
>   }
> }
> {code}
> Having *autoIndent* and *autoNewLine* set to *true* I expect a result similar to this:
> {code}
> <html>
>     <head>
>         <title>The title</title>
>         <meta name='title' content='The title'/>
>         <meta name='description' content='The description'/>
>     </head>
> </html>
> {code}
> But I get all elements in the same level as one string:
> {code}
> <html>
>     <head>
>         <title>The title</title><meta name='title' content='The title'/><meta name='description' content='The description'/>
>     </head>
> </html>
> {code}
> When there are a lot of elements in the same level leads to an unreadable formatting, what obviously isn't the purpose of pretty printing.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)