View Single Post
Old 04-28-2011, 09:29 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I was assuming that the values between the { } characters never contain newlines. I don't see why they should.

If this is true, then the following should work.
Code:
lines = text.split('\n')
result = []
for l in lines:
    result.append(composite_formatter.safe_format(l, mi, 'XXX', mi))
val = '\n'.join(result)
This code gives you back the multiline text, with template fields inserted.

Am I missing something?
chaley is offline   Reply With Quote