20 lines
563 B
Lua
20 lines
563 B
Lua
local M = {}
|
|
|
|
---@param ft string Filetype of template
|
|
---@param template string Template in language table
|
|
---@param name string A string to replace temp values in template
|
|
---@return string
|
|
function M.fetch(ft, template, name)
|
|
ft, template, name = ft or "", template or "", name or ""
|
|
if ft == "" or template == "" or name == "" then
|
|
return ""
|
|
end
|
|
local ok, mod = pcall(require, "vern.templates." .. ft)
|
|
if ok and type(mod) == "table" then
|
|
return (string.gsub(mod[template], "%%s", name))
|
|
end
|
|
return ""
|
|
end
|
|
|
|
return M
|