Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

This is the template function that was in my LuaJIT-driven HydroCL project. I liked it so much I put it in its own project, so other projects could use it.

Here's an example of how it works. Similar to PHP.

The 's wrap executed code and the wrap automatically printed code.

Dependencies:

Example:

local template = require 'template'
fields = {
	{a = 'int'},
	{b = 'const char*'},
	{c = 'double'},
}
print(template([[
typedef struct {
<? for _,name_ctype in ipairs(fields) do
	local name, ctype = next(name_ctype)
?>	<?=ctype?> <?=name?>;
<? end
?>} S;
]], {
	fields = fields,
}))

...produces...

typedef struct {
	int a;
	const char* b;
	double c;
} S;

...which fits perfectly inside a ffi.cdef() call.

About

No description, website, or topics provided.

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.