Jump to content

Module:Module sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Aerotinge (talk | contribs) at 03:56, 8 March 2025 (setting css variable via lua test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.generateVariable(frame)
  local variableName = frame.args.name
  local variableValue = frame.args.value

  if not variableName or not variableValue then
    return '<span style="color: red;">Error: Both "name" and "value" parameters are required.</span>'
  end

  local css = ':root { ' .. variableName .. ': ' .. variableValue .. '; }'
  local html = '<style>' .. css .. '</style>'

  return html
end

return p