Genie.Renderer.Html.normal_element — Functionnormal_element(f::Function, elem::String, attrs::Vector{Pair{Symbol,Any}} = Pair{Symbol,Any}[]) :: HTMLStringGenerates a HTML element in the form <...></...>
Genie.Renderer.Html.prepare_template — Functionprepare_template(s::String)
prepare_template{T}(v::Vector{T})Cleans up the template before rendering (ex by removing empty nodes).
Genie.Renderer.Html.attributes — Functionattributes(attrs::Vector{Pair{Symbol,String}} = Vector{Pair{Symbol,String}}()) :: Vector{String}Parses HTML attributes.
Genie.Renderer.Html.parseattr — Functionparseattr(attr) :: StringConverts Julia keyword arguments to HTML attributes with illegal Julia chars.
Genie.Renderer.Html.normalize_element — Functionnormalize_element(elem::String)Cleans up problematic characters or DOM elements.
Genie.Renderer.Html.denormalize_element — Functiondenormalize_element(elem::String)Replaces - with the char defined to replace dashes, as Julia does not support them in names.
Genie.Renderer.Html.void_element — Functionvoid_element(elem::String, attrs::Vector{Pair{Symbol,String}} = Vector{Pair{Symbol,String}}()) :: HTMLStringGenerates a void HTML element in the form <...>
Genie.Renderer.Html.get_template — Functionget_template(path::String; partial::Bool = true, context::Module = @__MODULE__, vars...) :: FunctionResolves the inclusion and rendering of a template file
Genie.Renderer.Html.doctype — FunctionOutputs document's doctype.
Genie.Renderer.Html.doc — FunctionOutputs document's doctype.
Genie.Renderer.Html.parseview — Functionparseview(data::String; partial = false, context::Module = @__MODULE__) :: FunctionParses a view file, returning a rendering function. If necessary, the function is JIT-compiled, persisted and loaded into memory.
Genie.Renderer.Html.render — Functionrender(data::String; context::Module = @__MODULE__, layout::Union{String,Nothing} = nothing, vars...) :: FunctionRenders the string as an HTML view.
render(viewfile::Genie.Renderer.FilePath; layout::Union{Nothing,Genie.Renderer.FilePath} = nothing, context::Module = @__MODULE__, vars...) :: FunctionRenders the template file as an HTML view.
Genie.Renderer.Html.parsehtml — Functionparsehtml(input::String; partial::Bool = true) :: Stringparsehtml(elem, output; partial = true) :: StringParses a HTML tree structure into a string of Julia code.
Genie.Renderer.render — FunctionrenderAbstract function that needs to be specialized by individual renderers.
Genie.Renderer.Html.html — Functionhtml(data::String; context::Module = @__MODULE__, status::Int = 200, headers::HTTPHeaders = HTTPHeaders(), layout::Union{String,Nothing} = nothing, vars...) :: HTTP.ResponseParses the data input as HTML, returning a HTML HTTP Response.
Arguments
data::String: the HTML string to be renderedcontext::Module: the module in which the variables are evaluated (in order to provide the scope for vars). Usually the controller.status::Int: status code of the responseheaders::HTTPHeaders: HTTP response headerslayout::Union{String,Nothing}: layout file for renderingdata
Example
julia> html("<h1>Welcome $(vars(:name))</h1>", layout = "<div><% @yield %></div>", name = "Adrian")
HTTP.Messages.Response:
"
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
<html><head></head><body><div><h1>Welcome Adrian</h1>
</div></body></html>"html(md::Markdown.MD; context::Module = @__MODULE__, status::Int = 200, headers::Genie.Renderer.HTTPHeaders = Genie.Renderer.HTTPHeaders(), layout::Union{String,Nothing} = nothing, forceparse::Bool = false, vars...) :: Genie.Renderer.HTTP.ResponseMarkdown view rendering
html(viewfile::FilePath; layout::Union{Nothing,FilePath} = nothing,
context::Module = @__MODULE__, status::Int = 200, headers::HTTPHeaders = HTTPHeaders(), vars...) :: HTTP.ResponseParses and renders the HTML viewfile, optionally rendering it within the layout file. Valid file format is .html.jl.
Arguments
viewfile::FilePath: filesystem path to the view file as aRenderer.FilePath, ieRenderer.filepath("/path/to/file.html.jl")orpath"/path/to/file.html.jl"layout::FilePath: filesystem path to the layout file as aRenderer.FilePath, ieRenderer.FilePath("/path/to/file.html.jl")orpath"/path/to/file.html.jl"context::Module: the module in which the variables are evaluated (in order to provide the scope for vars). Usually the controller.status::Int: status code of the responseheaders::HTTPHeaders: HTTP response headers
Genie.Renderer.Html.safe_attr — Functionsafe_attr(attr) :: StringReplaces illegal Julia characters from HTML attributes with safe ones, to be used as keyword arguments.
Genie.Renderer.Html.html_to_julia — Functionhtml_to_julia(file_path::String; partial = true) :: StringConverts a HTML document to Julia code.
Genie.Renderer.Html.string_to_julia — Functionstring_to_julia(content::String; partial = true, f_name::Union{Symbol,Nothing} = nothing, prepend = "") :: StringConverts string view data to Julia code
Genie.Renderer.Html.to_julia — Functionto_julia(input::String, f::Function; partial = true, f_name::Union{Symbol,Nothing} = nothing, prepend = "") :: StringConverts an input file to Julia code
Genie.Renderer.Html.partial — Functionpartial(path::String; context::Module = @__MODULE__, vars...) :: StringRenders (includes) a view partial within a larger view or layout file.
Genie.Renderer.Html.template — Functiontemplate(path::String; partial::Bool = true, context::Module = @__MODULE__, vars...) :: StringRenders a template file.
Genie.Renderer.Html.read_template_file — Functionread_template_file(file_path::String) :: StringReads file_path template from disk.
Genie.Renderer.Html.parse_template — Functionparse_template(file_path::String; partial = true) :: StringParses a HTML file into Julia code.
Genie.Renderer.Html.parse_string — Functionparse_string(data::String; partial = true) :: StringParses a HTML string into Julia code.
Genie.Renderer.Html.register_elements — Functionregister_elements() :: NothingGenerated functions that represent Julia functions definitions corresponding to HTML elements.
Genie.Renderer.Html.register_element — Functionregister_element(elem::Union{Symbol,String}, elem_type::Union{Symbol,String} = :normal; context = @__MODULE__) :: NothingGenerates a Julia function representing an HTML element.
Genie.Renderer.Html.register_normal_element — Functionregister_normal_element(elem::Union{Symbol,String}; context = @__MODULE__) :: NothingGenerates a Julia function representing a "normal" HTML element: that is an element with a closing tag, <tag>...</tag>
Genie.Renderer.Html.register_void_element — Functionregister_void_element(elem::Union{Symbol,String}; context::Module = @__MODULE__) :: NothingGenerates a Julia function representing a "void" HTML element: that is an element without a closing tag, <tag />
Genie.Renderer.Html.for_each — Functionfor_each(f::Function, v)Iterates over the v Vector and applies function f for each element. The results of each iteration are concatenated and the final string is returned.
Genie.Renderer.Html.collection — Functioncollection(template::Function, collection::Vector{T})::String where {T}Creates a view fragment by repeateadly applying a function to each element of the collection.
Genie.Router.error — FunctionerrorNot implemented function for error response.
Genie.Renderer.Html.serve_error_file — Functionserve_error_file(error_code::Int, error_message::String = "", params::Dict{Symbol,Any} = Dict{Symbol,Any}()) :: ResponseServes the error file correspoding to error_code and current environment.
Genie.Renderer.Html.@yield — Macro@yieldOutputs the rendering of the view within the template.