diff --git a/src/HypertextLiteral.jl b/src/HypertextLiteral.jl index 736a41b..533b171 100644 --- a/src/HypertextLiteral.jl +++ b/src/HypertextLiteral.jl @@ -32,9 +32,7 @@ See also: [`@htl`](@ref), [`HypertextLiteral.@htl_str`](@ref) """ module HypertextLiteral -@static if VERSION >= v"1.3" - using Tricks: static_hasmethod -end +using Tricks: compat_hasmethod export @htl, @htl_str diff --git a/src/convert.jl b/src/convert.jl index 7ce20b1..70d476f 100644 --- a/src/convert.jl +++ b/src/convert.jl @@ -86,36 +86,21 @@ used. Otherwise, the result is printed within a `` tag, using a serialized as: `missing`. """ content -@static if VERSION >= v"1.3" - function content(x::T) where {T} - if static_hasmethod(show, Tuple{IO, MIME{Symbol("text/html")}, T}) - return Render(x) - else - mod = parentmodule(T) - cls = string(nameof(T)) - if mod == Core || mod == Base || pathof(mod) !== nothing - cls = join(fullname(mod), "-") * "-" * cls - end - span = """""" - return reprint(Bypass(span), x, Bypass("")) - end - end -else - @generated function content(x) - if hasmethod(show, Tuple{IO, MIME{Symbol("text/html")}, x}) - return :(Render(x)) - else - mod = parentmodule(x) - cls = string(nameof(x)) - if mod == Core || mod == Base || pathof(mod) !== nothing - cls = join(fullname(mod), "-") * "-" * cls - end - span = """""" - return :(reprint(Bypass($span), x, Bypass(""))) +function content(x::T) where {T} + if compat_hasmethod(show, Tuple{IO, MIME{Symbol("text/html")}, T}) + return Render(x) + else + mod = parentmodule(T) + cls = string(nameof(T)) + if mod == Core || mod == Base || pathof(mod) !== nothing + cls = join(fullname(mod), "-") * "-" * cls end + span = """""" + return reprint(Bypass(span), x, Bypass("")) end end + function reprint(xs...) # generated functions cannot contain a closure Reprint() do io::IO