Changed the files to work with templates

This commit is contained in:
DarthMooMancer
2025-04-17 20:39:25 -04:00
parent a5c8a04e0f
commit 11ecd94afd
10 changed files with 352 additions and 348 deletions
+4 -46
View File
@@ -1,55 +1,13 @@
local utils = require("Polydev.utils")
---@type table
local M = {}
---@type table|nil
M.opts = nil
---@param opts table
function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("html"), opts or {})
end
function M.create_project()
vim.ui.input({ prompt = "Enter project name: " }, function(project_name)
if not project_name or project_name == "" then return print("Project creation canceled.") end
local project_root = vim.fn.expand(M.opts.project_root) .. "/" .. project_name
local main_html_content = [[
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
]]
utils.write_file(project_root .. "index.html", main_html_content)
end)
end
function M.create_new_file()
vim.ui.input({ prompt = "Enter page name: " }, function(page)
if not page or page == "" then return print("Class creation canceled.") end
local html_content = string.format([[
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
]])
utils.write_file("./" .. page .. ".html", html_content)
end)
end
---@return table
return M