1 | -- resty-gitweb@utils/nav.lua |
2 | -- Builds HTML anchors for navigation |
3 |
|
4 | -- Copyright (c) 2020 Joshua 'joshuas3' Stockin |
5 | -- <https://git.joshstock.in/resty-gitweb> |
6 | -- This software is licensed under the MIT License. |
7 |
|
8 | local _M = function(nav_data, join) |
9 | join = join or " | " |
10 | local build = {} |
11 | for _, link in pairs(nav_data) do |
12 | local url = link[1] |
13 | local text = link[2] |
14 | local f = string.format([[<a class="link" href="%s">%s</a>]], url, text) |
15 | table.insert(build, f) |
16 | end |
17 | return string.format([[<span class="nav">%s</span>]], table.concat(build, join)) |
18 | end |
19 |
|
20 | return _M |
21 |
|