mirror of
https://github.com/TangentFoxy/etlua.git
synced 2025-07-27 18:42:17 +00:00
rename project to etlua
This commit is contained in:
4
Makefile
4
Makefile
@@ -3,7 +3,7 @@ test:
|
||||
busted
|
||||
|
||||
build::
|
||||
moonc elua.moon
|
||||
moonc etlua.moon
|
||||
|
||||
local: build
|
||||
luarocks make --local elua-dev-1.rockspec
|
||||
luarocks make --local etlua-dev-1.rockspec
|
||||
|
14
README.md
14
README.md
@@ -1,18 +1,18 @@
|
||||
# elua
|
||||
# etlua
|
||||
|
||||
Embedded Lua templating
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ luarocks install --server=http://rocks.moonscript.org elua
|
||||
$ luarocks install --server=http://rocks.moonscript.org etlua
|
||||
```
|
||||
|
||||
## Tutorial
|
||||
|
||||
```lua
|
||||
local elua = require "elua"
|
||||
local template = elua.compile([[
|
||||
local etlua = require "etlua"
|
||||
local template = etlua.compile([[
|
||||
Hello <%= name %>,
|
||||
Here are your items:
|
||||
<% for i, item in pairs(items) do %>
|
||||
@@ -41,19 +41,19 @@ following newline if there is one, for example: `<%= 'hello' -%>`.
|
||||
The module can be loaded by doing:
|
||||
|
||||
```lua
|
||||
local elua = require "elua"
|
||||
local etlua = require "etlua"
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
#### `func = elua.compile(template_string)`
|
||||
#### `func = etlua.compile(template_string)`
|
||||
|
||||
Compiles the template into a function, the returned function can be called to
|
||||
render the template. The function takes one argument: a table to use as the
|
||||
environment within the template. `_G` is used to look up a variable if it can't
|
||||
be found in the environment.
|
||||
|
||||
#### `result = elua.render(template_string, env)`
|
||||
#### `result = etlua.render(template_string, env)`
|
||||
|
||||
Compiles and renders the template in a single call. If you are concerned about
|
||||
high performance this should be avoided in favor of `compile` if it's possible
|
||||
|
30
etlua-1.0.0-1.rockspec
Normal file
30
etlua-1.0.0-1.rockspec
Normal file
@@ -0,0 +1,30 @@
|
||||
package = "etlua"
|
||||
version = "1.0.0-1"
|
||||
|
||||
source = {
|
||||
url = "git://github.com/leafo/etlua.git",
|
||||
branch = "v1.0.0"
|
||||
}
|
||||
|
||||
description = {
|
||||
summary = "Embedded templates for Lua",
|
||||
detailed = [[
|
||||
Allows you to render ERB style templates but with Lua. Supports <% %>, <%=
|
||||
%> and <%- %> tags (with optional newline slurping) for embedding code.
|
||||
]],
|
||||
homepage = "https://github.com/leafo/etlua",
|
||||
maintainer = "Leaf Corcoran <leafot@gmail.com>",
|
||||
license = "MIT"
|
||||
}
|
||||
|
||||
dependencies = {
|
||||
"lua >= 5.1",
|
||||
}
|
||||
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
["etlua"] = "etlua.lua",
|
||||
},
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package = "elua"
|
||||
package = "etlua"
|
||||
version = "dev-1"
|
||||
|
||||
source = {
|
||||
url = "git://github.com/leafo/elua.git"
|
||||
url = "git://github.com/leafo/etlua.git"
|
||||
}
|
||||
|
||||
description = {
|
||||
@@ -11,7 +11,7 @@ description = {
|
||||
Allows you to render ERB style templates but with Lua. Supports <% %>, <%=
|
||||
%> and <%- %> tags (with optional newline slurping) for embedding code.
|
||||
]],
|
||||
homepage = "https://github.com/leafo/elua",
|
||||
homepage = "https://github.com/leafo/etlua",
|
||||
maintainer = "Leaf Corcoran <leafot@gmail.com>",
|
||||
license = "MIT"
|
||||
}
|
||||
@@ -23,7 +23,7 @@ dependencies = {
|
||||
build = {
|
||||
type = "builtin",
|
||||
modules = {
|
||||
["elua"] = "elua.lua",
|
||||
["etlua"] = "etlua.lua",
|
||||
},
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ do
|
||||
end,
|
||||
load = function(self, code, name)
|
||||
if name == nil then
|
||||
name = "elua"
|
||||
name = "etlua"
|
||||
end
|
||||
local code_fn = coroutine.wrap(function()
|
||||
return coroutine.yield(code)
|
@@ -161,7 +161,7 @@ class Parser
|
||||
source_line = get_line @str, source_line_no
|
||||
"#{err_msg} [#{source_line_no}]: #{source_line}"
|
||||
|
||||
load: (code, name="elua") =>
|
||||
load: (code, name="etlua") =>
|
||||
code_fn = coroutine.wrap ->
|
||||
coroutine.yield code
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
import compile, render, Parser from require "elua"
|
||||
import compile, render, Parser from require "etlua"
|
||||
|
||||
describe "elua", ->
|
||||
describe "etlua", ->
|
||||
describe "Parser", ->
|
||||
cases = {
|
||||
{
|
Reference in New Issue
Block a user