Module:Genre

local utils = require('Module:Utils') local yesno = require('Dev:Yesno') local categorize = utils.categorize('Catalog', 'Community') local p = {} local genres = {'Building', 'Horror', 'Town and city', 'Military', 'Comedy', 'Fighting', 'Medieval', 'Adventure', 'Sci-fi', 'FPS', 'Naval', 'RPG', 'Sports', 'Western'} function p._format_genre(args) local genre_name = args.genre or 'All' -- Assume 'All' if no genre was given. local genre_string = genre_name:lower -- Use the lowercase string for comparisons. if genre_string == 'all' then return " All" else for _, genre in next, genres do			if genre:lower == genre_string then return " " .. genre .. (args["category suffix"] and (categorize(genre .. " " .. args["category suffix"])) or "") end end -- If the function didn't return in the loop, the genre string corresponded to none of the recognized genres. return error("Invalid genre") end end p.format_genre = utils.make_wrapper_function(p._format_genre) function p._enumerate_genres(args) local output = "" if args.genres then -- If there are multiple genres, list them. -- Otherwise, we want to format the only genre without putting it in a list. if args.genres:find('/') or args.genres:find(',') then for genre in args.genres:gmatch('%s*([^/,]+)') do output = output .. "\n* " .. p._format_genre {genre = genre, ["category suffix"] = args["category suffix"]} end output = output:sub(2) -- Remove the initial newline. else output = p._format_genre {genre = args.genres, ["category suffix"] = args["category suffix"]} end else -- If no genres were specified, default to 'All'. output = p._format_genre {genre = 'All', ["category suffix"] = args["category suffix"]} end return output end p.enumerate_genres = utils.make_wrapper_function(p._enumerate_genres) return p