|
1 | 1 | package = "luax"
|
2 |
| -version = "1.0.1-2" |
| 2 | +version = "1.0.2-1" |
3 | 3 |
|
4 | 4 | source = {
|
5 |
| - url = "https://github.com/syarul/luax/archive/refs/tags/v1.0.1.tar.gz", |
6 |
| - dir = "luax-1.0.1" |
| 5 | + url = "https://github.com/syarul/luax/archive/refs/tags/v1.0.2.tar.gz", |
| 6 | + dir = "luax-1.0.2" |
7 | 7 | }
|
8 | 8 | description = {
|
9 | 9 | summary = "HTML parse in Lua",
|
10 |
| - detailed = [[## LuaX |
11 |
| -Decent parse for HTML, so you don't have to write as concatenates string, in short a React JSX implementation in LUA. |
12 |
| -
|
13 |
| -<a href="https://luarocks.org/modules/syarul/luax" rel="nofollow"><img alt="Luarocks Package" src="https://img.shields.io/badge/Luarocks-1.0.1-blue.svg" style="max-width:100%;"></a> |
14 |
| -[](https://github.com/syarul/luax/actions/workflows/lua.yml) |
15 |
| -
|
16 |
| -### Usage |
17 |
| -
|
18 |
| -```lua |
19 |
| -local h = require('h') |
20 |
| -
|
21 |
| -local el = div( |
22 |
| - { class = "container" }, |
23 |
| - p({ class = "title" }, "Hello, world!"), |
24 |
| - span({ style = "color: red;" }, "This is a span") |
25 |
| -) |
26 |
| -
|
27 |
| -print(h(el)) |
28 |
| -``` |
29 |
| -
|
30 |
| -You'll get, |
31 |
| -
|
32 |
| -```html |
33 |
| -<div class="container"><p class="title">Hello, world!</p><span style="color: red;">This is a span</span></div> |
34 |
| -``` |
35 |
| -
|
36 |
| -### Usage with JSX like syntax (HTML inside Lua) |
37 |
| -
|
38 |
| -first create a `*.luax` file, then import the `LuaX` pragma `h` |
39 |
| -
|
40 |
| -```lua |
41 |
| --- el.luax |
42 |
| -local class = "container" |
43 |
| -local el = <div id="hello" class={class}>Hello, world!</div> |
44 |
| -return el |
45 |
| -``` |
46 |
| -
|
47 |
| -import it on to the main |
48 |
| -```lua |
49 |
| -local h = require('luax') |
50 |
| -
|
51 |
| -local el = require('el') |
52 |
| -
|
53 |
| -print(h(el)) |
54 |
| -``` |
55 |
| -
|
56 |
| -You'll get, |
57 |
| -
|
58 |
| -```html |
59 |
| -<div class="container" id="hello">Hello, world!</div> |
60 |
| -``` |
61 |
| -
|
62 |
| -Sample usage with list/table structure |
63 |
| -
|
64 |
| -```lua |
65 |
| -local function map(a, fcn) |
66 |
| - local b = {} |
67 |
| - for _, v in ipairs(a) do |
68 |
| - table.insert(b, fcn(v)) |
69 |
| - end |
70 |
| - return b |
71 |
| -end |
72 |
| -
|
73 |
| -local filters = { |
74 |
| - { url = "#/", name = "All", selected = true }, |
75 |
| - { url = "#/active", name = "Active", selected = false }, |
76 |
| - { url = "#/completed", name = "Completed", selected = false }, |
77 |
| -} |
78 |
| -
|
79 |
| -local content = table.concat(map(filters, function(filter) |
80 |
| - return h(<li> |
81 |
| - <a |
82 |
| - class={filter.selected and 'selected' or nil} |
83 |
| - href={filter.url} |
84 |
| - _="on click add .selected to me" |
85 |
| - > |
86 |
| - {filter.name} |
87 |
| - </a> |
88 |
| - </li>) |
89 |
| -end), '\n') |
90 |
| -
|
91 |
| -return <ul class="filters" _="on load set $filter to me"> |
92 |
| - {content} |
93 |
| -</ul> |
94 |
| -``` |
95 |
| -
|
96 |
| -See the test folder to see more usage cases. |
97 |
| -
|
98 |
| -> Inspired by https://bvisness.me/luax/. |
99 |
| -]], |
| 10 | + detailed = "LuaX is Lua + XML Syntax extension with builtin decent parse. In retrospect it's akin to React JSX.", |
100 | 11 | homepage = "https://github.com/syarul/luax",
|
101 | 12 | license = "MIT"
|
102 | 13 | }
|
|
0 commit comments