Skip to content

notactuallytreyanastasio/heex-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

heex-lua

HEEx template parser for Lua. Parse Phoenix LiveView templates in Lua applications.

Installation

Download from GitHub Releases:

# Download the latest release
curl -LO https://github.com/notactuallytreyanastasio/heex-lua/releases/latest/download/heex-lua.tar.gz
tar -xzf heex-lua.tar.gz

Usage

local heex = require("heex")

-- Parse a HEEx template
local doc = heex.parse([[
    <div class={@class}>
      <.button variant="primary">
        Click me
      </.button>
    </div>
]])

-- Render back to HTML
print(heex.render_html(doc))

-- Get JSON AST for tooling
print(heex.render_json(doc))

-- Debug tree view
print(heex.render_debug(doc))

API

heex.parse(template: string): Document

Parses a HEEx template string and returns an AST.

heex.render_html(doc: Document): string

Renders the AST back to an HTML string.

heex.render_json(doc: Document): string

Renders the AST as a JSON string (useful for tooling).

heex.render_debug(doc: Document): string

Renders a debug tree view of the AST.

Supported Syntax

  • HTML elements and attributes
  • Self-closing elements (<br />, <input>)
  • Phoenix components (.button, MyApp.Button)
  • Slots (:header, :footer)
  • Expressions ({@value}, {@user.name})
  • Dynamic attributes (class={@class})
  • Spread attributes ({@rest})
  • Special attributes (:if, :for, :let)
  • EEx tags (<%= %>, <% %>, <%# %>)
  • HTML comments (<!-- -->)

Requirements

  • Lua 5.1+ or LuaJIT

Source

Generated from httpeex using Temper.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages