Skip to content

Commit

Permalink
accept AbstractStrings and Vectors for headconent, accept head_conten…
Browse files Browse the repository at this point in the history
…t in DEFAULT_LAYOUT
  • Loading branch information
hhaensel committed Jan 17, 2024
1 parent 63fa969 commit 8c1b15b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ julia> layout([
```
"""
function layout(output::Union{S,Vector}, m::M;
partial::Bool = false, title::String = "", class::String = "", style::String = "", head_content::String = "",
partial::Bool = false, title::String = "", class::String = "", style::String = "", head_content::Union{AbstractString, Vector{<:AbstractString}} = "",
channel::String = Stipple.channel_js_name,
core_theme::Bool = true)::ParsedHTMLString where {M<:ReactiveModel, S<:AbstractString}

Expand All @@ -58,7 +58,7 @@ function layout(output::Union{S,Vector}, m::M;
Genie.Renderer.Html.head([
Genie.Renderer.Html.title(title)
Genie.Renderer.Html.meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no")
head_content
join(head_content)
])
Genie.Renderer.Html.body(content, class=class, style=style)
])
Expand All @@ -83,7 +83,7 @@ julia> page(:elemid, [
"""
function page(model::M, args...;
partial::Bool = false, title::String = "", class::String = "container", style::String = "",
channel::String = Genie.config.webchannels_default_route, head_content::String = "",
channel::String = Genie.config.webchannels_default_route, head_content::Union{AbstractString, Vector{<:AbstractString}} = "",
prepend::Union{S,Vector} = "", append::Union{T,Vector} = [],
core_theme::Bool = true, kwargs...)::ParsedHTMLString where {M<:Stipple.ReactiveModel, S<:AbstractString,T<:AbstractString}

Expand Down
3 changes: 2 additions & 1 deletion src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}()
const HANDLERS_FUNCTIONS = LittleDict{Type{<:ReactiveModel},Function}()

function DEFAULT_LAYOUT(; title::String = "Genie App",
meta::D = Dict()) where {D <:AbstractDict}
meta::D = Dict(), head_content::Union{AbstractString, Vector} = "") where {D <:AbstractDict}
tags = Genie.Renderers.Html.for_each(x -> """<meta name="$(string(x.first))" content="$(string(x.second))">\n""", meta)
"""
<!DOCTYPE html>
Expand All @@ -64,6 +64,7 @@ function DEFAULT_LAYOUT(; title::String = "Genie App",
}
._genie .row .col-12 { width:50%;margin:auto; }
</style>
$(join(head_content, "\n "))
</head>
<body>
<div class='container'>
Expand Down

0 comments on commit 8c1b15b

Please sign in to comment.