Commit d8d01d8f authored by Michal Čihař's avatar Michal Čihař

Prevent losing leading new line in <textarea>

parent a12c2024
......@@ -11,6 +11,9 @@ class PluralTextarea(forms.Textarea):
lang, value = value
if not isinstance(value, list):
attrs['class'] = 'translation'
# Prevent losing leading new line in <textarea>
if value[0] == '\n':
value = '\n' + value
return super(PluralTextarea, self).render(name, value, attrs)
ret = []
for idx, val in enumerate(value):
......@@ -20,6 +23,9 @@ class PluralTextarea(forms.Textarea):
else:
fieldname = name
attrs['class'] = 'translation'
# Prevent losing leading new line in <textarea>
if val[0] == '\n':
val = '\n' + val
textarea = super(PluralTextarea, self).render(fieldname, val, attrs)
label = lang.get_plural_label(idx)
ret.append('<label class="plural" for="%s">%s</label><br />%s' % (attrs['id'], label, textarea))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment