Модуль:tableofrecipes
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
| Строка 102: | Строка 101: | ||
local function createLinkToRow(ingredientId, ingredientName) | local function createLinkToRow(ingredientId, ingredientName) | ||
return string.format("[[#%s|%s]]", ingredientId, ingredientName) | return string.format("[[#%s|%s]]", ingredientId, ingredientName) | ||
end | |||
-- Форматирование температуры для отображения | |||
local function formatTemperature(recipe) | |||
local tempString = "" | |||
-- Проверяем наличие минимальной температуры | |||
local hasMin = recipe.minTemp and recipe.minTemp ~= 0 | |||
-- Проверяем наличие максимальной температуры (если есть поле maxTemp) | |||
local hasMax = recipe.maxTemp and recipe.maxTemp ~= 0 | |||
if hasMin and hasMax then | |||
tempString = string.format("от %sК до %sК", recipe.minTemp, recipe.maxTemp) | |||
elseif hasMin then | |||
tempString = string.format("выше %sК", recipe.minTemp) | |||
elseif hasMax then | |||
tempString = string.format("ниже %sК", recipe.maxTemp) | |||
else | |||
tempString = "Нет данных" | |||
end | |||
return tempString | |||
end | end | ||
| Строка 225: | Строка 246: | ||
local result = resultData.name or "Нет результата" | local result = resultData.name or "Нет результата" | ||
local resultImage = resultData.image or "" | local resultImage = resultData.image or "" | ||
local minTemp = recipe | |||
local minTemp = formatTemperature(recipe) | |||
templateArgs.input = input .. " " .. inputImage | templateArgs.input = input .. " " .. inputImage | ||
templateArgs.result = result .. " " .. resultImage | templateArgs.result = result .. " " .. resultImage | ||
templateArgs.minTemp = minTemp | templateArgs.minTemp = minTemp | ||
-- Обработка для toolmadeRecipes | -- Обработка для toolmadeRecipes | ||