lua.model.mustache Maven / Gradle / Ivy
{{#models}}
{{#model}}
{{>partial_header}}
-- {{classname}} class
local {{classname}} = {}
local {{classname}}_mt = {
__name = "{{classname}}";
__index = {{classname}};
}
local function cast_{{classname}}(t)
return setmetatable(t, {{classname}}_mt)
end
local function new_{{classname}}({{#vars}}{{name}}{{^-last}}, {{/-last}}{{/vars}})
return cast_{{classname}}({
{{#vars}}
["{{baseName}}"] = {{name}};
{{/vars}}
})
end
return {
cast = cast_{{classname}};
new = new_{{classname}};
}
{{/model}}
{{/models}}