From 027f6613c4531686a2b647bd974be37d1be081f4 Mon Sep 17 00:00:00 2001 From: Adrian Salceanu Date: Wed, 28 Feb 2024 15:26:41 +0100 Subject: [PATCH] Allow non registered html elements --- Project.toml | 2 +- src/renderers/Html.jl | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 6d6ab1749..42ea3d832 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Genie" uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e" authors = ["Adrian Salceanu and the amazing Genie contributors ♥️"] -version = "5.26.0" +version = "5.26.1" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/renderers/Html.jl b/src/renderers/Html.jl index 0dd085806..7bad3e7e1 100644 --- a/src/renderers/Html.jl +++ b/src/renderers/Html.jl @@ -134,7 +134,20 @@ end Generates a HTML element in the form <...> """ function normal_element(f::Function, elem::Any, args::Vector = [], attrs::Vector{Pair{Symbol,Any}} = Pair{Symbol,Any}[]) :: HTMLString - normal_element(Base.invokelatest(f), string(elem), args, attrs...) + try + normal_element(Base.invokelatest(f), string(elem), args, attrs...) + catch ex + @warn ex + if isa(ex, UndefVarError) # tag function does not exist, let's register it + try + register_normal_element(ex.var |> string) + normal_element(Base.invokelatest(f), string(elem), args, attrs...) + catch ex + @error ex + "" + end + end + end end function normal_element(children::Union{T,Vector{T}}, elem::Any, args::Vector, attrs::Pair{Symbol,Any})::HTMLString where {T<:AbstractString} normal_element(children, string(elem), args, Pair{Symbol,Any}[attrs])