Avoid new break line in groovy template

What I observed (from answer, comments and some practice) is : All new Lines, we created inside the file applications.config are considered as new line in the output. As daggett said it is a default thing.

So Here I just want to show the possible config file format, where can be applied some conditional logic as u asked and looks ok for me. ex : if()

application.config :

<% applications.each { application ->
 if (application.valid) {%>\
Type :<%=application.valid%>
<%} else{%>\
Found invalid Application : <%= application.name %>


- name: service1
  port: 8080
  path: /servier1
  valid: true
- name: service2
  port: 8081
  path: /service2
  valid: false


import org.yaml.snakeyaml.Yaml

Yaml parser = new Yaml()
Map data = parser.load(("applications.yaml" as File).text)

String template_content = new File('applications.config').text

def binding = [applications: data.applications]
def template = new groovy.text.GStringTemplateEngine().createTemplate(template_content).make(binding)
println template.toString()

Output :

Type :true
Found invalid Application : service2

look at your template for example from notepad++ (JSP language):

enter image description here

at the end of first line <% applications.each { application -> %> there is a CRLF that will be printed out before each Application

and in the next line another CRLF that will be printed after each Application.

so you have two CRLF between each two apps