diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 0c769a5884364b25471e5abce0ab5abfe29293b1..294b2578a11f7f3bd89e06cf49a1fa732e3fd0b4 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -10,6 +10,7 @@ use HTTP::AcceptLanguage;
 use Log::Any::Adapter;
 use List::MoreUtils qw(uniq);
 use Template;
+use Template::Constants qw(:chomp);
 use Text::CSV;
 
 use AccountManager::Account;
@@ -179,7 +180,8 @@ sub respond {
 
     ## Parse template
     my $tt2 = Template->new({
-        ENCODING => 'utf8',
+        ENCODING     => 'utf8',
+        PRE_CHOMP    => CHOMP_ONE,
         INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/web/$lang"
     });
 
@@ -480,7 +482,8 @@ sub req_complete_challenge {
     my $lang = HTTP::AcceptLanguage->new($ENV{HTTP_ACCEPT_LANGUAGE})->match(qw/en fr/) || 'en';
 
     my $tt2 = Template->new({
-        ENCODING => 'utf8',
+        ENCODING     => 'utf8',
+        PRE_CHOMP    => CHOMP_ONE,
         INCLUDE_PATH => $self->{configuration}->{setup}->{templates_dir} . "/mail/$lang"
     });
     my $template = 'send_authentication_token.tt2.eml';
diff --git a/lib/AccountManager/Tools.pm b/lib/AccountManager/Tools.pm
index 126b7c4563a6cc44145e266af7d147574efaea66..08287ed037643d06b0e123a29b7d3ec01653f371 100644
--- a/lib/AccountManager/Tools.pm
+++ b/lib/AccountManager/Tools.pm
@@ -10,6 +10,7 @@ use List::Util qw(shuffle);
 use List::MoreUtils qw(pairwise);
 use MIME::Base64;
 use Template;
+use Template::Constants qw(:chomp);
 use Template::Stash;
 
 sub encrypt {
@@ -109,6 +110,7 @@ sub update_ssp_authsources {
 
     my $tt2 = Template->new({
         ENCODING     => 'utf8',
+        PRE_CHOMP    => CHOMP_ONE,
         INCLUDE_PATH => $templates_dir . '/accounts'
     });
     my $template = 'accounts.php.tt2';
diff --git a/templates/accounts/accounts.php.tt2 b/templates/accounts/accounts.php.tt2
index 568ef2d223b5fe9e242bba73a31b4bb0619d9ffe..1f04f5af2df8ed7a37b0a9c5ace0949d6b379665 100644
--- a/templates/accounts/accounts.php.tt2
+++ b/templates/accounts/accounts.php.tt2
@@ -3,41 +3,41 @@
 $validTestAccounts = array (
     'authcrypt:Hash',
 
-[% FOREACH account IN accounts -%]
+[% FOREACH account IN accounts %]
     'user[% account.id() %]:{SHA256}[% account.password_hash() %]=' => array(
         'internal_uid'               => array([% account.internal_uid().quote %]),
         'associatedSP'               => array([% account.associatedSP().quote %]),
-    [% IF account.cn() -%]
+    [% IF account.cn() %]
         'cn'                         => array([% account.cn().quote %]),
-    [% END -%]
-    [% IF account.sn() -%]
+    [% END %]
+    [% IF account.sn() %]
         'sn'                         => array([% account.sn().quote %]),
-    [% END -%]
-    [% IF account.displayName() -%]
+    [% END %]
+    [% IF account.displayName() %]
         'displayName'                => array([% account.displayName().quote %]),
-    [% END -%]
-    [% IF account.givenName() -%]
+    [% END %]
+    [% IF account.givenName() %]
         'givenName'                  => array([% account.givenName().quote %]),
-    [% END -%]
-    [% IF account.mail() -%]
+    [% END %]
+    [% IF account.mail() %]
         'mail'                       => array([% account.mail().quote %]),
-    [% END -%]
-    [% IF account.eduPersonAffiliation() -%]
+    [% END %]
+    [% IF account.eduPersonAffiliation() %]
         'eduPersonAffiliation'       => array([% account.eduPersonAffiliation().quote.join(', ') %]),
-    [% END -%]
-    [% IF account.eduPersonScopedAffiliation() -%]
+    [% END %]
+    [% IF account.eduPersonScopedAffiliation() %]
         'eduPersonScopedAffiliation' => array([% account.eduPersonScopedAffiliation().quote.join(', ') %]),
-    [% END -%]
-    [% IF account.eduPersonPrincipalName() -%]
+    [% END %]
+    [% IF account.eduPersonPrincipalName() %]
         'eduPersonPrincipalName'     => array([% account.eduPersonPrincipalName().quote %]),
-    [% END -%]
-    [% IF account.schacHomeOrganization() -%]
+    [% END %]
+    [% IF account.schacHomeOrganization() %]
         'schacHomeOrganization'      => array([% account.schacHomeOrganization().quote %]),
-    [% END -%]
-    [% IF account.schacHomeOrganizationType() -%]
+    [% END %]
+    [% IF account.schacHomeOrganizationType() %]
         'schacHomeOrganizationType'  => array([% account.schacHomeOrganizationType().quote %]),
-    [% END -%]
+    [% END %]
     ),
 
-[% END -%]
+[% END %]
 );
diff --git a/templates/web/en/create_accounts.tt2.html b/templates/web/en/create_accounts.tt2.html
index 39a96030336965b32d8eefd49dce76f78de4290d..82c73df9e9001137760dee33e6ebbb12ecda900a 100644
--- a/templates/web/en/create_accounts.tt2.html
+++ b/templates/web/en/create_accounts.tt2.html
@@ -49,14 +49,14 @@ provider.</p>
         <div>
             <table>
                 <caption>List of user attributes</caption>
-    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] -%]
+    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] %]
                 <tr>
-                    <th>[% attribute %]</th><td> [% account.$attribute() %]</td>
+                    <th>[% attribute %]</th><td>[% account.$attribute() %]</td>
                 </tr>
     [% END %]
-    [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] -%]
+    [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
                 <tr>
-                    <th>[% attribute %]</th><td> [% account.$attribute().join(', ') %]</td>
+                    <th>[% attribute %]</th><td>[% account.$attribute().join(', ') %]</td>
                 </tr>
     [% END %]
                 <tr>
diff --git a/templates/web/fr/create_accounts.tt2.html b/templates/web/fr/create_accounts.tt2.html
index 162a6282a7a2ce6ff7a07c64f0896b41f8e696a6..b8bb6377e6c9c32aa5cfd8e3f26edf4a53e34b58 100644
--- a/templates/web/fr/create_accounts.tt2.html
+++ b/templates/web/fr/create_accounts.tt2.html
@@ -51,14 +51,14 @@ service fédéré. Pour le faire, sélectionnez <strong>[% idp_displayname
         <div>
             <table>
                 <caption>Liste des attributs utilisateur</caption>
-    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] -%]
+    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName' ] %]
                 <tr>
-                    <th>[% attribute %]</th><td> [% account.$attribute() %]</td>
+                    <th>[% attribute %]</th><td>[% account.$attribute() %]</td>
                 </tr>
     [% END %]
-    [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] -%]
+    [% FOREACH attribute IN [ 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
                 <tr>
-                    <th>[% attribute %]</th><td> [% account.$attribute().join(', ') %]</td>
+                    <th>[% attribute %]</th><td>[% account.$attribute().join(', ') %]</td>
                 </tr>
     [% END %]
                 <tr>