webmcp
diff framework/env/locale/do_with.lua @ 262:c3d539e33710
Replaced request.add_initializer(...) and request.add_variable(...) with request.for_each(...) and request.configure(...) which both execute the passed function once in any case when being called
author | jbe |
---|---|
date | Tue Mar 17 11:42:34 2015 +0100 (2015-03-17) |
parents | 9fdfb27f8e67 |
children |
line diff
1.1 --- a/framework/env/locale/do_with.lua Mon Mar 16 23:21:18 2015 +0100 1.2 +++ b/framework/env/locale/do_with.lua Tue Mar 17 11:42:34 2015 +0100 1.3 @@ -11,12 +11,16 @@ 1.4 --]]-- 1.5 1.6 function locale.do_with(locale_options, block) 1.7 - local old_data = {} 1.8 - for key, value in pairs(locale._current_data) do 1.9 - old_data[key] = value 1.10 + local old_data = table.new(locale._current_data) 1.11 + if locale_options.reset then 1.12 + locale._current_data = {} 1.13 + end 1.14 + for key, value in pairs(locale_options) do 1.15 + if key ~= "reset" then 1.16 + locale._current_data[key] = value 1.17 + end 1.18 end 1.19 locale.set(locale_options) 1.20 block() 1.21 - old_data.reset = true 1.22 - locale.set(old_data) 1.23 + locale._current_data = old_data 1.24 end