@@ -30,20 +30,44 @@ function LoadViewsRecursively(path)
3030end
3131
3232function Page (view , layout , bindVarsView , bindVarsLayout )
33- if (BeansEnv == " development" ) then
34- Views [" app/views/layouts/" .. layout .. " /index.html.etlua" ] = Etlua .compile (LoadAsset (" app/views/layouts/" ..
35- layout .. " /index.html.etlua" ))
36- end
33+ Variant = Variant or " "
3734
3835 if (BeansEnv == " development" ) then
39- Views [" app/views/" .. view .. " .etlua" ] = Etlua .compile (LoadAsset (" app/views/" .. view .. " .etlua" ))
36+ local asset = nil
37+ if Variant == " " then
38+ asset = LoadAsset (" app/views/layouts/" .. layout .. " /index.html.etlua" )
39+ Views [" app/views/layouts/" .. layout .. " /index.html.etlua" ] = Etlua .compile (asset )
40+ else
41+ asset = LoadAsset (" app/views/layouts/" .. layout .. " /index.html+" .. Variant .. " .etlua" )
42+ if asset == nil then
43+ asset = LoadAsset (" app/views/layouts/" .. layout .. " /index.html.etlua" )
44+ end
45+ Views [" app/views/layouts/" .. layout .. " /index.html+" .. Variant .. " .etlua" ] = Etlua .compile (asset )
46+ end
47+
48+ if Variant == " " then
49+ asset = LoadAsset (" app/views/" .. view .. " .etlua" )
50+ Views [" app/views/" .. view .. " .etlua" ] = Etlua .compile (asset )
51+ else
52+ asset = LoadAsset (" app/views/" .. view .. " +" .. Variant .. " .etlua" )
53+ if asset == nil then
54+ asset = LoadAsset (" app/views/" .. view .. " .etlua" )
55+ end
56+ Views [" app/views/" .. view .. " +" .. Variant .. " .etlua" ] = Etlua .compile (asset )
57+ end
4058 end
4159
42- layout = Views [" app/views/layouts/" .. layout .. " /index.html.etlua" ](bindVarsLayout or {})
60+ compiled_layout = Views [" app/views/layouts/" .. layout .. " /index.html.etlua" ]
61+ if Variant ~= " " then
62+ compiled_layout = Views [" app/views/layouts/" .. layout .. " /index.html+" .. Variant .. " .etlua" ] or compiled_layout
63+ end
64+ layout = compiled_layout (bindVarsLayout or {})
4365
44- if Views [" app/views/" .. view .. " .etlua" ] then
45- view = Views [" app/views/" .. view .. " .etlua" ](bindVarsView or {})
66+ compiled_view = Views [" app/views/" .. view .. " .etlua" ]
67+ if Variant ~= " " then
68+ compiled_view = Views [" app/views/" .. view .. " +" .. Variant .. " .etlua" ] or compiled_view
4669 end
70+ view = compiled_view (bindVarsView or {})
4771
4872 local content
4973 if view :find (" %%" ) then
0 commit comments