Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright 2025 Jesper Wendel Devantier

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# HTT - HTML/Text Templating

[![CI](https://github.com/jwdevantier/htt/actions/workflows/ci.yml/badge.svg)](https://github.com/jwdevantier/htt/actions/workflows/ci.yml)

HTT is a templating language built around Lua that excels at generating code and configuration files. It combines the readability of traditional templating with the full power of Lua.

## Key Features

- **Component-Based**: Build complex templates by composing smaller, reusable components
- **Full Lua Integration**: Use Lua for logic, data transformation, and external module integration
- **Smart Indentation**: Maintains correct indentation across component nesting levels
- **Efficient**: Templates are compiled to Lua modules and loaded lazily

## Documentation

Visit [https://jwdevantier.github.io/htt/](https://jwdevantier.github.io/htt/) for:
- Getting started guide
- Syntax reference
- Examples and best practices
- Detailed explanations of components, modules, and debugging
67 changes: 44 additions & 23 deletions api/api_desc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ local tcp_stream = {
content = {
{
name = "recv",
type = "function",
type = "method",
params = {
{ name = "buf", type = t_tcp_buffer, summary = "Buffer of data to send" },
{ name = "n", type = "integer", summary = "if provided, read exactly `n` bytes" },
Expand All @@ -180,7 +180,7 @@ local tcp_stream = {
},
{
name = "recv_at_least",
type = "function",
type = "method",
params = {
{ name = "buf", type = t_tcp_buffer, summary = "Buffer of data to send" },
{ name = "n", type = "integer", summary = "read at least this many bytes" },
Expand All @@ -195,7 +195,7 @@ local tcp_stream = {
},
{
name = "send",
type = "function",
type = "method",
params = {
{ name = "buffer", type = t_tcp_buffer, summary = "Buffer" },
{ name = "n", type = "integer?", summary = "if set, send the first n bytes, not entire buffer" },
Expand All @@ -216,7 +216,7 @@ local tcp_buffer = {
content = {
{
name = "remaining",
type = "function",
type = "method",
params = {
},
desc = {
Expand All @@ -230,7 +230,7 @@ local tcp_buffer = {
},
{
name = "size",
type = "function",
type = "method",
params = {
},
desc = {
Expand All @@ -244,7 +244,7 @@ local tcp_buffer = {
},
{
name = "set_size",
type = "function",
type = "method",
params = {
{ name = "N", type = "integer", "Desired size of the buffer, in bytes" }
},
Expand All @@ -259,7 +259,7 @@ local tcp_buffer = {
},
{
name = "seek",
type = "function",
type = "method",
params = {
{ name = "N", type = "integer", summary = "The byte offset to seek to" }
},
Expand All @@ -271,7 +271,7 @@ local tcp_buffer = {
},
{
name = "tell",
type = "function",
type = "method",
params = {
},
desc = {
Expand All @@ -283,7 +283,7 @@ local tcp_buffer = {
},
{
name = "write_string",
type = "function",
type = "method",
params = {
{ name = "str", type = "string", summary = "the string to write" }
},
Expand All @@ -297,7 +297,7 @@ local tcp_buffer = {
},
{
name = "write_bool",
type = "function",
type = "method",
params = {
{ name = "val", type = "boolean", summary = "the value to write" }
},
Expand All @@ -311,7 +311,7 @@ local tcp_buffer = {
},
{
name = "read_string",
type = "function",
type = "method",
params = {
{ name = "len", type = "integer", summary = "length, in bytes, of string" }
},
Expand All @@ -326,7 +326,7 @@ local tcp_buffer = {
},
{
name = "read_bool",
type = "function",
type = "method",
params = {
},
desc = {
Expand Down Expand Up @@ -354,7 +354,7 @@ for _, signedness in ipairs({ "i", "u" }) do
end
table.insert(tcp_buffer.content, {
name = string.format("write_%s%s%s", signedness, bits, order),
type = "function",
type = "method",
params = {
{ name = "val", type = "integer", summary = "value to write" },
},
Expand Down Expand Up @@ -386,7 +386,7 @@ for _, signedness in ipairs({ "i", "u" }) do
end
table.insert(tcp_buffer.content, {
name = string.format("read_%s%s%s", signedness, bits, order),
type = "function",
type = "method",
params = {
},
desc = {
Expand Down Expand Up @@ -690,7 +690,7 @@ m_fs.content = {
content = {
{
name = "path",
type = "function",
type = "method",
params = {
},
desc = {
Expand All @@ -702,7 +702,7 @@ m_fs.content = {
},
{
name = "make_path",
type = "function",
type = "method",
params = {
{ name = "subpath", type = "path", summary = "path of dirs, relative to dir, to create" },
},
Expand All @@ -718,7 +718,7 @@ m_fs.content = {
},
{
name = "open_dir",
type = "function",
type = "method",
params = {
{ name = "subpath", type = "string", summary = "path relative to dir of directory to open" },
},
Expand All @@ -732,7 +732,7 @@ m_fs.content = {
},
{
name = "parent",
type = "function",
type = "method",
params = {
},
desc = {
Expand All @@ -745,7 +745,7 @@ m_fs.content = {
},
{
name = "list",
type = "function",
type = "method",
params = {},
desc = {
"Return iterator to loop over all items in directory.",
Expand All @@ -757,7 +757,7 @@ m_fs.content = {
},
{
name = "walk",
type = "function",
type = "method",
params = {},
desc = {
"Return iterator for recursively iterating through all contents nested under dir.",
Expand All @@ -769,7 +769,7 @@ m_fs.content = {
},
{
name = "remove",
type = "function",
type = "method",
params = {
{ name = "subpath", type = "string?", summary = "(optional) a path relative to this directory. Otherwise this directory." }
},
Expand All @@ -785,7 +785,7 @@ m_fs.content = {
},
{
name = "exists",
type = "function",
type = "method",
params = {
{ name = "subpath", type = "string?", summary = "(optional) either check subpath relative to directory, or directory itself" },
},
Expand All @@ -799,7 +799,7 @@ m_fs.content = {
},
{
name = "touch",
type = "function",
type = "method",
params = {
{ name = "subpath", type = "string", summary = "path of file to create, relative to directory" },
},
Expand Down Expand Up @@ -1102,10 +1102,31 @@ local m_json = {
}
}

local htt_component = {
name = "Component",
type = "type",
content = {
{
name = "is",
type = "function",
params = {
{ name = "value", type = "any", summary = "some value to check" },
},
desc = {
"Check whether value is a HTT template component"
},
returns = {
{ type = "boolean", summary = "true if a ComponentInstance, false otherwise" },
}
},
},
}

htt.name = "htt"
htt.summary = "HTT utility API"
htt.class = "htt"
htt.content = {
htt_component,
m_str,
m_env,
m_tcp,
Expand Down
Loading
Loading