lapis
lapis copied to clipboard
Documentation bug. `HTML Generation` page does not have lua version for examples
seen at http://leafo.net/lapis/reference/html_generation.html
Not sure if you're the person to answer this but I created the html generator syntax with moonscript in mind. Would people want to write that syntax in lua? It becomes pretty verbose. I made etlua specifically for lua users but never really polled any lua users to see what they prefer.
Anyway, that's why there aren't any docs for it currently, but I can either add some or put a note about it.
I feel like the clarification you just presented is helpful- I feel like the docs generally give the impression that the moonscript and lua approaches generally have equivalent functionality. Making it clear that the html options are moonscript and etlua is helpful to me.
Came here with the same problem, would be good to maybe just have your comment above or words to the same effect at the top of the documentation page for html generation.
Is it worth also providing lua translations of the html builders? Would anyone use it?
It's hard to say without seeing one. At the very least a note that etlua plays thank role. It's just that the documentation naturally indicates that there is a lua version, so it just struck me as odd when I found it for some things but not others. Erik On Aug 22, 2015 12:38 PM, leaf [email protected] wrote:Is it worth also providing lua translations of the html builders? Would anyone use it?
—Reply to this email directly or view it on GitHub.
I'd definitely use a Lua version of it if it's made.
I`d too.
I'd too. I don't like moonscript.. :(
If it's still wanted, I wouldn't mind going through and converting the MoonScript version of the examples to Lua, and submitting a pull for it.
I think a note should definitely be added to the top to say that this isn't recommended however. @leafo How would I add a note to the top that only shows up on the Lua version? I figured out how with the code examples, but not with anything else.
Yes, it's still wanted.
Just submitted a pull for it..but it's not very complete, as a lot of the HTML generation stuff is based on MoonScript classes. I honestly do not think this is a good idea in its current state. If anyone else wants to work on it, please do.
Yes, some general info on how to invoke the builder would be nice. Not just for Lua. For example, the same call structure can be created in Fennel:
(html #(
div { :class "main container" } #(
(h1 #(
(text "SuperApp ")
(sup (. Config app_version))))
(p #(
(text "This is the debug interface. Use the ")
(a { :href "#" } "API")
(text " to build stuff. Don't rely on this interface. If you're not a developer, you shouldn't be here."))))))
produces this Lua code:
_1_(...)
local function _2_()
local function _3_()
local function _4_()
return text("SuperApp ")(sup(Config[app_version]))
end
local function _5_()
return text("This is the debug interface. Use the ")(a({href = "#"}, "API"), text(" to build stuff. Don't rely on this interface. If you're not a developer, you shouldn't be here."))
end
return h1(_4_)(p(_5_))
end
return div({class = "main container"}, _3_)
end
return html(_2_)
(I know there's a Fennel HTML generator, but it's not as sophisticated as Lapis')
Even if it's literally just the HTML builder. Then it can be applied to other frameworks which rely less on MoonScript (e.g. Turbo.lua (no affiliation with me)).
Nevermind, with @TangentFoxy's example, this works:
(let [render_html (. (assert (require "lapis.html")) :render_html)]
(print (render_html
#(html
#(div { :class "main container" } #(do
(h1 #(do
(text "SuperApp")
(sup "2019.3")))
(p #(do
(text "This is the debug interface. Use the ")
(a { :href "#" } "API")
(text " to build stuff. Don't rely on this interface. If you're not a developer, you shouldn't be here.")))))))))
We then have to teach HTML tag names to the Fennel compiler so it doesn't complain about undeclared globals:
fennel --globals html,div,h1,text,sup,p,a test.fnl
@turbo Oh I'm glad to know that worked out for you! :D