Browse Source

[Minor] Update lua-lupa

 - Fixed bug where 'else' was not evaluated if 'elseif' is present.
tags/3.0
Andrew Lewis 3 years ago
parent
commit
fe3cb3a530
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      contrib/lua-lupa/lupa.lua

+ 5
- 1
contrib/lua-lupa/lupa.lua View File

@@ -1,4 +1,4 @@
-- Copyright 2015-2020 Mitchell. See LICENSE.
-- Sponsored by the Library of the University of Antwerp.
-- Contributions from Ana Balan.
-- Lupa templating engine.
@@ -457,15 +457,18 @@ local function evaluate(ast, env)
if eval(block.expression, env) then
chunks[#chunks + 1] = evaluate(block, env)
else
local evaluate_else = true
local elseifs = block['elseif']
if elseifs then
for j = 1, #elseifs do
if eval(elseifs[j].expression, env) then
chunks[#chunks + 1] = evaluate(elseifs[j], env)
evaluate_else = false
break
end
end
elseif block['else'] then
end
if evaluate_else and block['else'] then
chunks[#chunks + 1] = evaluate(block['else'], env)
end
end

Loading…
Cancel
Save