From 50b724400204a1b76bd18869f09c9d16b469f43f Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 17 Nov 2020 09:23:21 +0100
Subject: [PATCH] no need to reload templates

---
 templates/other/accounts.csv.tt2 | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/templates/other/accounts.csv.tt2 b/templates/other/accounts.csv.tt2
index ec26aac..531f2a6 100644
--- a/templates/other/accounts.csv.tt2
+++ b/templates/other/accounts.csv.tt2
@@ -1,17 +1,22 @@
-[% all_attributes = {} %]
+[%
+    attributes_all = {}
+    attributes_for = {}
+%]
 [% FOREACH account IN accounts %]
+    [% id = account.id() %]
     [% template = account.profile() _ '.tt2' %]
     [% PROCESS $template scope=account.scope() id=account.id() | trim %]
-    [% all_attributes.import(attributes) %]
+    [% attributes_all.import(attributes) %]
+    [% attributes_for.$id = attributes %]
 [% END %]
-[% attributes_list = all_attributes.keys.sort -%]
+[% attributes_list = attributes_all.keys.sort -%]
 username,password,profile,[% attributes_list.join(',') %]
 [%+ FOREACH account IN accounts %]
-    [% template = account.profile() _ '.tt2' %]
-    [% PROCESS $template scope=account.scope() id=account.id() | trim %]
+    [% id = account.id() %]
     [% account.internal_uid() %],
     [% account.password() %],
     [% account.profile() %],
+    [% attributes = attributes_for.$id %]
     [% FOREACH attribute IN attributes_list %]
         [% attributes.$attribute.join(', ').quote('"') %],
     [% END %]
-- 
GitLab