public function addVariable(string $name, $value)
    {
        // Convert value to something usable in the output
        if (WF::is_array_like($value))
        {
            $value = WF::to_array($value);
        }
        elseif (is_subclass_of($value, JSONSerializable::class))
        {
            $value = $value->jsonSerialize();
        }
        elseif (!is_scalar($value))
        {
            throw new InvalidArgumentException("Invalid value provided for JS variable $name");
        }

        $this->inline_variables[$name] = $value;
        return $this;
    }