Having conditionals for a Lua DSL?
snippet in lua

Having conditionals for a Lua DSL?

user8575

x = '10'

function if_x (v)
  if x == v then
    return function (s)
      assert(loadstring(s))()
    end
  end
  return function() end
end

if_x '10' [[print('x is 10')]]
if_x '20' [[print('x is 20')]]