mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
gui.template test
This commit is contained in:
parent
0863e40b3b
commit
e059b9395f
3 changed files with 50 additions and 0 deletions
|
|
@ -201,6 +201,19 @@ function time.post_runnable(runnable)
|
|||
table.insert(__post_runnables, runnable)
|
||||
end
|
||||
|
||||
function gui.template(name, params)
|
||||
local text = file.read(file.find("layouts/templates/"..name..".xml"))
|
||||
for k,v in pairs(params) do
|
||||
text = text:gsub("(%%{"..k.."})", tostring(v))
|
||||
end
|
||||
text = text:gsub("if%s*=%s*'%%{%w+}'", "if=''")
|
||||
text = text:gsub("if%s*=%s*\"%%{%w+}\"", "if=\"\"")
|
||||
-- remove unsolved properties: attr='%{var}'
|
||||
text = text:gsub("%w+%s*=%s*'%%{%w+}'%s?", "")
|
||||
text = text:gsub("%w+%s*=%s*\"%%{%w+}\"%s?", "")
|
||||
return text
|
||||
end
|
||||
|
||||
-- Deprecated functions
|
||||
block_index = block.index
|
||||
block_name = block.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue