Две мысли:
Правые строки Ли с тройными кавычками не обрабатываются каким-либо специальным образом, но поскольку вы используете Groovy, достаточно легко получить желаемое поведение:
def description = '''Join the Perl programmers of the Pork Producers
of America as we hone our skills and ham it up
a bit. You can show off your programming chops
while trying to win a year's supply of pork
chops in our programming challenge.
Come and join us in historic (and aromatic),
Austin, Minnesota. You'll know when you're
there!'''
description.split("\n").collect { it.trim() }.join(" ")
печатает:
Join the Perl programmers of the Pork Producers of America as we hone our skills and ham it up a bit. You can show off your programming chops while trying to win a year's supply of pork chops in our programming challenge. Come and join us in historic (and aromatic), Austin, Minnesota. You'll know when you're there!
Если вам нужно дополнительное форматирование, вы можете изучить синтаксис markdown и библиотеку MarkdownJ . На самом деле я только что вчера выпустил плагин Grails Markdown , который принимает форматированный текст с уценкой и превращает его в HTML для GSP.
Да, это ожидается . Тройные кавычки - это всего лишь многострочная строка, нет никакой магии для обнаружения и удаления отступов.
если вы просто откажетесь от требований форматирования и отформатируете ее как
description: '''Join the Perl programmers of the Pork Producers
of America as we hone our skills and ham it up
a bit. You can show off your programming chops
while trying to win a year's supply of pork
chops in our programming challenge.
Come and join us in historic (and aromatic),
Austin, Minnesota. You'll know when you're
there!'''
, то вы получите желаемую строку без необходимости ее последующей обработки. Выглядит неплохо, имхо ...
Чтобы воспользоваться предыдущим ответом, сделайте следующее:
def description = '''\
Join the Perl programmers of the Pork Producers
of America as we hone our skills and ham it up
a bit. You can show off your programming chops
while trying to win a year's supply of pork
chops in our programming challenge.
Come and join us in historic (and aromatic),
Austin, Minnesota. You'll know when you're
there!'''
с текстовым форматом довольно легко работать. Обратная косая черта (), за которой сразу следует конец строки (EOL), будет проглочена. (См. http://docs.codehaus.org/display/GroovyJSR/Groovy+String+Handling )