Genie.Renderer.Html.normal_element - Function
normal_element(f::Function, elem::String, attrs::Vector{Pair{Symbol,Any}} = Pair{Symbol,Any}[]) :: HTMLString

Generates a HTML element in the form <...></...>

source


Genie.Renderer.Html.prepare_template - Function
prepare_template(s::String)
prepare_template{T}(v::Vector{T})

Cleans up the template before rendering (ex by removing empty nodes).

source


Genie.Renderer.Html.attributes - Function
attributes(attrs::Vector{Pair{Symbol,String}} = Vector{Pair{Symbol,String}}()) :: Vector{String}

Parses HTML attributes.

source


Genie.Renderer.Html.parseattr - Function
parseattr(attr) :: String

Converts Julia keyword arguments to HTML attributes with illegal Julia chars.

source


Genie.Renderer.Html.normalize_element - Function
normalize_element(elem::String)

Cleans up problematic characters or DOM elements.

source


Genie.Renderer.Html.denormalize_element - Function
denormalize_element(elem::String)

Replaces - with the char defined to replace dashes, as Julia does not support them in names.

source


Genie.Renderer.Html.void_element - Function
void_element(elem::String, attrs::Vector{Pair{Symbol,String}} = Vector{Pair{Symbol,String}}()) :: HTMLString

Generates a void HTML element in the form <...>

source


Genie.Renderer.Html.get_template - Function
get_template(path::String; partial::Bool = true, context::Module = @__MODULE__, vars...) :: Function

Resolves the inclusion and rendering of a template file

source


Genie.Renderer.Html.doctype - Function

Outputs document's doctype.

source


Genie.Renderer.Html.doc - Function

Outputs document's doctype.

source


Genie.Renderer.Html.parseview - Function
parseview(data::String; partial = false, context::Module = @__MODULE__) :: Function

Parses a view file, returning a rendering function. If necessary, the function is JIT-compiled, persisted and loaded into memory.

source


Genie.Renderer.Html.render - Function
render(data::String; context::Module = @__MODULE__, layout::Union{String,Nothing} = nothing, vars...) :: Function

Renders the string as an HTML view.

source

render(viewfile::Genie.Renderer.FilePath; layout::Union{Nothing,Genie.Renderer.FilePath} = nothing, context::Module = @__MODULE__, vars...) :: Function

Renders the template file as an HTML view.

source


Genie.Renderer.Html.parsehtml - Function
parsehtml(input::String; partial::Bool = true) :: String

source

parsehtml(elem, output; partial = true) :: String

Parses a HTML tree structure into a string of Julia code.

source


Genie.Renderer.render - Function
render

Abstract function that needs to be specialized by individual renderers.

source


Genie.Renderer.Html.html - Function
html(data::String; context::Module = @__MODULE__, status::Int = 200, headers::HTTPHeaders = HTTPHeaders(), layout::Union{String,Nothing} = nothing, vars...) :: HTTP.Response

Parses the data input as HTML, returning a HTML HTTP Response.

Arguments

  • data::String: the HTML string to be rendered
  • 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 response
  • headers::HTTPHeaders: HTTP response headers
  • layout::Union{String,Nothing}: layout file for rendering data

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>"

source

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.Response

Markdown view rendering

source

html(viewfile::FilePath; layout::Union{Nothing,FilePath} = nothing,
      context::Module = @__MODULE__, status::Int = 200, headers::HTTPHeaders = HTTPHeaders(), vars...) :: HTTP.Response

Parses 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 a Renderer.FilePath, ie Renderer.filepath("/path/to/file.html.jl") or path"/path/to/file.html.jl"
  • layout::FilePath: filesystem path to the layout file as a Renderer.FilePath, ie Renderer.FilePath("/path/to/file.html.jl") or path"/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 response
  • headers::HTTPHeaders: HTTP response headers

source


Genie.Renderer.Html.safe_attr - Function
safe_attr(attr) :: String

Replaces illegal Julia characters from HTML attributes with safe ones, to be used as keyword arguments.

source


Genie.Renderer.Html.html_to_julia - Function
html_to_julia(file_path::String; partial = true) :: String

Converts a HTML document to Julia code.

source


Genie.Renderer.Html.string_to_julia - Function
string_to_julia(content::String; partial = true, f_name::Union{Symbol,Nothing} = nothing, prepend = "") :: String

Converts string view data to Julia code

source


Genie.Renderer.Html.to_julia - Function
to_julia(input::String, f::Function; partial = true, f_name::Union{Symbol,Nothing} = nothing, prepend = "") :: String

Converts an input file to Julia code

source


Genie.Renderer.Html.partial - Function
partial(path::String; context::Module = @__MODULE__, vars...) :: String

Renders (includes) a view partial within a larger view or layout file.

source


Genie.Renderer.Html.template - Function
template(path::String; partial::Bool = true, context::Module = @__MODULE__, vars...) :: String

Renders a template file.

source


Genie.Renderer.Html.read_template_file - Function
read_template_file(file_path::String) :: String

Reads file_path template from disk.

source


Genie.Renderer.Html.parse_template - Function
parse_template(file_path::String; partial = true) :: String

Parses a HTML file into Julia code.

source


Genie.Renderer.Html.parse_string - Function
parse_string(data::String; partial = true) :: String

Parses a HTML string into Julia code.

source


Genie.Renderer.Html.register_elements - Function
register_elements() :: Nothing

Generated functions that represent Julia functions definitions corresponding to HTML elements.

source


Genie.Renderer.Html.register_element - Function
register_element(elem::Union{Symbol,String}, elem_type::Union{Symbol,String} = :normal; context = @__MODULE__) :: Nothing

Generates a Julia function representing an HTML element.

source


Genie.Renderer.Html.register_normal_element - Function
register_normal_element(elem::Union{Symbol,String}; context = @__MODULE__) :: Nothing

Generates a Julia function representing a "normal" HTML element: that is an element with a closing tag, <tag>...</tag>

source


Genie.Renderer.Html.register_void_element - Function
register_void_element(elem::Union{Symbol,String}; context::Module = @__MODULE__) :: Nothing

Generates a Julia function representing a "void" HTML element: that is an element without a closing tag, <tag />

source


Genie.Renderer.Html.for_each - Function
for_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.

source


Genie.Renderer.Html.collection - Function
collection(template::Function, collection::Vector{T})::String where {T}

Creates a view fragment by repeateadly applying a function to each element of the collection.

source


Genie.Router.error - Function
error

Not implemented function for error response.

source


Genie.Renderer.Html.serve_error_file - Function
serve_error_file(error_code::Int, error_message::String = "", params::Dict{Symbol,Any} = Dict{Symbol,Any}()) :: Response

Serves the error file correspoding to error_code and current environment.

source


Genie.Renderer.Html.@yield - Macro
@yield

Outputs the rendering of the view within the template.

source



Genie