| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Html.Element
Description
Overview
Miso.Html.Element provides smart constructors for every HTML element. Each constructor has the signature:
tagName_ :: [Attributeaction] -> [Viewmodel action] ->Viewmodel action
All names are suffixed with _ to avoid clashing with Haskell
Prelude names (e.g. div_, head_, map_).
This module is re-exported in its entirety by Miso.Html and Miso.
Quick start
import Miso view :: Model ->ViewModel Action view m =div_[] [h1_[] [text"Hello, miso!" ] ,p_[class_"intro" ] [text"Counter: ",text(msm) ] ,button_[onClickIncrement ] [text"+" ] ]
Element groups
- Document metadata:
html_,head_,base_,link_,meta_,style_,title_,doctype_ - Sectioning:
body_,address_,article_,aside_,footer_,header_,h1_–h6_,hgroup_,main_,nav_,section_,search_ - Text content:
blockquote_,dd_,div_,dl_,dt_,figcaption_,figure_,hr_,li_,menu_,ol_,p_,pre_,ul_ - Inline semantics:
a_,abbr_,b_,bdi_,bdo_,br_,cite_,code_,data_,dfn_,em_,i_,kbd_,mark_,q_,rp_,rt_,ruby_,s_,samp_,small_,span_,strong_,sub_,sup_,time_,u_,var_,wbr_ - Embedded content:
audio_,canvas_,embed_,iframe_,img_,map_,object_,picture_,portal_,source_,track_,video_ - Scripting:
noscript_,script_ - Edits:
del_,ins_ - Table:
caption_,col_,colgroup_,table_,tbody_,td_,tfoot_,th_,thead_,tr_ - Forms:
button_,datalist_,fieldset_,form_,input_,label_,legend_,meter_,optgroup_,option_,output_,progress_,select_,textarea_ - Interactive:
details_,dialog_,summary_ - Custom:
nodeHtmlfor any tag name not listed above
See also
- Miso.Html.Property —
id_,class_,src_, … - Miso.Html.Event —
onClick,onInput, … - Miso.Html.Render — server-side HTML rendering via
ToHtml - Miso.Svg.Element — SVG element constructors
Synopsis
- nodeHtml :: MisoString -> [Attribute action] -> [View model action] -> View model action
- html_ :: [Attribute action] -> [View model action] -> View model action
- doctype_ :: View model action
- base_ :: [Attribute action] -> View model action
- head_ :: [Attribute action] -> [View model action] -> View model action
- link_ :: [Attribute action] -> View model action
- meta_ :: [Attribute action] -> View model action
- style_ :: [Attribute action] -> MisoString -> View model action
- title_ :: [Attribute action] -> [View model action] -> View model action
- body_ :: [Attribute action] -> [View model action] -> View model action
- address_ :: [Attribute action] -> [View model action] -> View model action
- article_ :: [Attribute action] -> [View model action] -> View model action
- aside_ :: [Attribute action] -> [View model action] -> View model action
- footer_ :: [Attribute action] -> [View model action] -> View model action
- header_ :: [Attribute action] -> [View model action] -> View model action
- h1_ :: [Attribute action] -> [View model action] -> View model action
- h2_ :: [Attribute action] -> [View model action] -> View model action
- h3_ :: [Attribute action] -> [View model action] -> View model action
- h4_ :: [Attribute action] -> [View model action] -> View model action
- h5_ :: [Attribute action] -> [View model action] -> View model action
- h6_ :: [Attribute action] -> [View model action] -> View model action
- hgroup_ :: [Attribute action] -> [View model action] -> View model action
- main_ :: [Attribute action] -> [View model action] -> View model action
- nav_ :: [Attribute action] -> [View model action] -> View model action
- section_ :: [Attribute action] -> [View model action] -> View model action
- search_ :: [Attribute action] -> [View model action] -> View model action
- blockquote_ :: [Attribute action] -> [View model action] -> View model action
- dd_ :: [Attribute action] -> [View model action] -> View model action
- div_ :: [Attribute action] -> [View model action] -> View model action
- dl_ :: [Attribute action] -> [View model action] -> View model action
- dt_ :: [Attribute action] -> [View model action] -> View model action
- figcaption_ :: [Attribute action] -> [View model action] -> View model action
- figure_ :: [Attribute action] -> [View model action] -> View model action
- hr_ :: [Attribute action] -> View model action
- li_ :: [Attribute action] -> [View model action] -> View model action
- menu_ :: [Attribute action] -> [View model action] -> View model action
- ol_ :: [Attribute action] -> [View model action] -> View model action
- p_ :: [Attribute action] -> [View model action] -> View model action
- pre_ :: [Attribute action] -> [View model action] -> View model action
- ul_ :: [Attribute action] -> [View model action] -> View model action
- a_ :: [Attribute action] -> [View model action] -> View model action
- abbr_ :: [Attribute action] -> [View model action] -> View model action
- b_ :: [Attribute action] -> [View model action] -> View model action
- bdi_ :: [Attribute action] -> [View model action] -> View model action
- bdo_ :: [Attribute action] -> [View model action] -> View model action
- br_ :: [Attribute action] -> View model action
- cite_ :: [Attribute action] -> [View model action] -> View model action
- code_ :: [Attribute action] -> [View model action] -> View model action
- data_ :: [Attribute action] -> [View model action] -> View model action
- dfn_ :: [Attribute action] -> [View model action] -> View model action
- em_ :: [Attribute action] -> [View model action] -> View model action
- i_ :: [Attribute action] -> [View model action] -> View model action
- kbd_ :: [Attribute action] -> [View model action] -> View model action
- mark_ :: [Attribute action] -> [View model action] -> View model action
- q_ :: [Attribute action] -> [View model action] -> View model action
- rp_ :: [Attribute action] -> [View model action] -> View model action
- rt_ :: [Attribute action] -> [View model action] -> View model action
- ruby_ :: [Attribute action] -> [View model action] -> View model action
- s_ :: [Attribute action] -> [View model action] -> View model action
- samp_ :: [Attribute action] -> [View model action] -> View model action
- small_ :: [Attribute action] -> [View model action] -> View model action
- span_ :: [Attribute action] -> [View model action] -> View model action
- strong_ :: [Attribute action] -> [View model action] -> View model action
- sub_ :: [Attribute action] -> [View model action] -> View model action
- sup_ :: [Attribute action] -> [View model action] -> View model action
- time_ :: [Attribute action] -> [View model action] -> View model action
- u_ :: [Attribute action] -> [View model action] -> View model action
- var_ :: [Attribute action] -> [View model action] -> View model action
- wbr_ :: [Attribute action] -> View model action
- area_ :: [Attribute action] -> View model action
- audio_ :: [Attribute action] -> [View model action] -> View model action
- img_ :: [Attribute action] -> View model action
- map_ :: [Attribute action] -> [View model action] -> View model action
- track_ :: [Attribute action] -> View model action
- video_ :: [Attribute action] -> [View model action] -> View model action
- embed_ :: [Attribute action] -> View model action
- fencedframe_ :: [Attribute action] -> [View model action] -> View model action
- iframe_ :: [Attribute action] -> [View model action] -> View model action
- object_ :: [Attribute action] -> [View model action] -> View model action
- picture_ :: [Attribute action] -> [View model action] -> View model action
- source_ :: [Attribute action] -> View model action
- canvas_ :: [Attribute action] -> [View model action] -> View model action
- noscript_ :: [Attribute action] -> [View model action] -> View model action
- script_ :: [Attribute action] -> MisoString -> View model action
- del_ :: [Attribute action] -> [View model action] -> View model action
- ins_ :: [Attribute action] -> [View model action] -> View model action
- caption_ :: [Attribute action] -> [View model action] -> View model action
- col_ :: [Attribute action] -> View model action
- colgroup_ :: [Attribute action] -> [View model action] -> View model action
- table_ :: [Attribute action] -> [View model action] -> View model action
- tbody_ :: [Attribute action] -> [View model action] -> View model action
- td_ :: [Attribute action] -> [View model action] -> View model action
- tfoot_ :: [Attribute action] -> [View model action] -> View model action
- th_ :: [Attribute action] -> [View model action] -> View model action
- thead_ :: [Attribute action] -> [View model action] -> View model action
- tr_ :: [Attribute action] -> [View model action] -> View model action
- button_ :: [Attribute action] -> [View model action] -> View model action
- datalist_ :: [Attribute action] -> [View model action] -> View model action
- fieldset_ :: [Attribute action] -> [View model action] -> View model action
- form_ :: [Attribute action] -> [View model action] -> View model action
- input_ :: [Attribute action] -> View model action
- label_ :: [Attribute action] -> [View model action] -> View model action
- legend_ :: [Attribute action] -> [View model action] -> View model action
- meter_ :: [Attribute action] -> [View model action] -> View model action
- optgroup_ :: [Attribute action] -> [View model action] -> View model action
- option_ :: [Attribute action] -> [View model action] -> View model action
- output_ :: [Attribute action] -> [View model action] -> View model action
- progress_ :: [Attribute action] -> [View model action] -> View model action
- select_ :: [Attribute action] -> [View model action] -> View model action
- textarea_ :: [Attribute action] -> View model action
- details_ :: [Attribute action] -> [View model action] -> View model action
- dialog_ :: [Attribute action] -> [View model action] -> View model action
- summary_ :: [Attribute action] -> [View model action] -> View model action
- slot_ :: [Attribute action] -> [View model action] -> View model action
- template_ :: [Attribute action] -> [View model action] -> View model action
- svg_ :: [Attribute action] -> [View model action] -> View model action
Smart constructors
Document metadata
style_ :: [Attribute action] -> MisoString -> View model action Source #
This takes the raw text to be put in the style tag.
That means that if any part of the text is not trusted there's a potential CSS injection.
You can also easily shoot yourself in the foot with something like:
style_ [] "</style>"
You can use style_ as a safer anternative.
Sectioning root
Content sectioning
Text content
Inline text semantics
Image and multimedia
Embedded content
fencedframe_ :: [Attribute action] -> [View model action] -> View model action Source #
Since: 1.9.0.0
Scripting
script_ :: [Attribute action] -> MisoString -> View model action Source #
This takes the raw text to be put in the script tag.
That means that if any part of the text is not trusted there's a potential JavaScript injection. Read more at https://owasp.org/www-community/attacks/xss/
You can also easily shoot yourself in the foot with something like:
script_ [] "</script>"Demarcating edits
Table content
Forms
form_ :: [Attribute action] -> [View model action] -> View model action Source #
For usage in a real-world application with the onSubmit event.
view :: Model -> View model action view model = form_ [ onSubmit NoOp ] [ input [ type_ "submit" ] ]
Note: onSubmit will use preventDefault = True. This will keep
the form from submitting to the server.
textarea_ :: [Attribute action] -> View model action Source #
textarea_ [ id_ "txt", P.value_ (model ^. txt) ]
When compiling on the server, this combinator will render HTML as <textarea>text</textarea>.
Since: 1.9.0.0