minijinja-lua 0.1.2

lua bindings for minijinja
Documentation

minijinja-lua

A Lua module for minijinja via mlua bindings

Installation

# with lux
lx install minijinja-lua

# with luarocks
luarocks install minijinja-lua

Usage

mj = require("minijinja")

env = mj.Environment:new()

env:add_template("my_temp", "Test: {{ foo | lua_filter }}")

local function lua_filter(state, val)
    return val:upper()
end

env:add_filter("lua_filter", lua_filter)

local ctx = {
    foo = "foo"
}

env:render_template("my_temp", ctx)
-- output: "TEST: FOO"

The API is documented in the minijinja.lua file, which should work with LuaLS or EmmyluaLS.

Development

Contributing

Contributions are welcome! Feel free to open bug reports, feature requests, or PRs.

AI Policy

AI is not allowed for communication, such as PR or issue report body content.

Getting Started

This project uses the nightly rust toolchain and the lux package manager for development. Pre-commit hooks are provided through prek.

If you do not already have rust installed, you can find directions here

To install lux, follow the directions here

To install prek, follow the directions here

Setup
# Clone the repo
git clone https://github.com/benniekiss/minijinja-lua
cd minijinja-lua

# Install the toolchain for the project
rustup install

# If you need to install lux
cargo install lux-cli
lx sync

# If you need to install prek
cargo install prek
prek install-hooks

Linting and Formatting

Make sure to run cargo fmt, cargo check, and cargo clippy prior to any submissions.

Tests

Lua tests are within the spec/ directory and use busted. The tests can be run with lx test

Rust unit tests can be run with cargo test.

Building

To build the project as a lua module, run lx build, or cargo build --no-default-features --features module,lua{version}, where {version} is one of 55, 54, 53, 52, or 51.

To build it as a library, run cargo build.

Submitting PRs

Please follow the Conventional Commits specification for PR titles.