<script type="application/lua">
Embed Lua code into your Web page, load remote Lua scripts, organise your code into modules and use JavaScript APIs and the DOM in Lua with ease. Starlight translates Lua to ES2015, discover more in the docs.
<script type="application/lua">
for i = 1, 15 do
local result = {}
if i % 3 == 0 then
table.insert(result, 'Fizz')
end
if i % 5 == 0 then
table.insert(result, 'Buzz')
end
print(#result > 0 and table.concat(result) or i)
end
</script>
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Package Lua in your front-end build scripts
Use the grunt-starlight
plugin to precompile all your Lua scripts to JavaScript. Discover more in the docs.
grunt.loadNpmTasks('grunt-starlight');
grunt.initConfig({
starlight: {
'hello-world': {
src: 'src/lua/hello-world.lua',
dest: 'dist/js/hello-world.lua.js',
},
},
});