REFACTOR: Completely changed how project creation is done so I can make
other languages easier and hopefully faster
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
local M = {}
|
||||
|
||||
---@param ft string Filetype of template
|
||||
---@param template string Template in language table
|
||||
---@param path string Filetype of template
|
||||
---@param kind 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
|
||||
function M.fetch(kind_path, kind, name)
|
||||
kind_path, kind, name = kind_path or "", kind or "", name or ""
|
||||
if kind_path == "" or kind == "" or name == "" then
|
||||
return ""
|
||||
end
|
||||
local ok, mod = pcall(require, "vern.templates." .. ft)
|
||||
local ok, mod = pcall(require, kind_path)
|
||||
if ok and type(mod) == "table" then
|
||||
return (string.gsub(mod[template], "%%s", name))
|
||||
return (string.gsub(mod[kind], "%%s", name))
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user