-- ROBLOX deviation START: handle template data

local function maybeHandleTemplateString(table_: any): Global_EachTable
	if typeof(table_) == "string" then
		local templateString = table_ :: string
		local raw = templateString
		local strings = {}
		local expressions = {}
		local startIndex = 1
		local endIndex = 1
		local expressionStarted = false
		for i = 1, #templateString do
			local current = string.sub(templateString, i, i)
			local next = if i < #templateString then string.sub(templateString, i + 1, i + 1) else nil
			if i == #templateString then
				if expressionStarted then
					error("expression not closed")
				end
				table.insert(strings, string.sub(templateString, startIndex))
			elseif not expressionStarted and current == "$" then
				if next == "{" then
					expressionStarted = true
					endIndex = i - 1
				end
			elseif expressionStarted and current == "}" then
				local str = string.sub(templateString, startIndex, endIndex)
				local exp = string.sub(templateString, endIndex + 3, i - 1)
				table.insert(strings, str)
				table.insert(expressions, exp)
				startIndex = i + 1
				expressionStarted = false
			end
		end

		return (setmetatable(strings, {
			__index = {
				raw = raw,
			},
		}) :: any) :: Global_EachTable
	else
		return table_
	end
end