Genie Discord forum
I'm writing a GenieBuilder app that uses
@page("/", "app.jl.html"). I'd like to render different views depending on the contents of the User-Agent header, but I'm unclear how to do this using the
@page macro. Is this possible or will I have to switch to calling
route() directly? How would either solution look?
In order to access the route parameters you'd have to use the low-code Stipple API instead of defining the UI with HTML.
Define a ui() function, and in it you can access the route parameters with Genie.Router.params. Just make sure that the function returns the UI as an array of calls to the StippleUI API
using GenieFramework @genietools @handlers begin end function ui() params = Genie.Router.params() println(params) [cell("Div 1"), cell("Div 2")] end @page("/", ui)
Thanks. Is there any way to utilize GB's
app.jl.html file from within
Good question! I had not thought of that. Yes, you can also return a string with the HTML code. Just read the html file:
function ui() pload = Genie.Router.params() println(pload) read("app.jl.html", String) end