Class: Phlex::HTML Abstract

Inherits:
SGML
  • Object
show all
Extended by:
ElementClobberingGuard, Elements
Includes:
StandardElements, VoidElements
Defined in:
lib/phlex/html.rb

Overview

This class is abstract.

Subclass and define SGML#template to create an HTML component class.

Defined Under Namespace

Modules: StandardElements, VoidElements

Constant Summary collapse

EVENT_ATTRIBUTES =

A list of HTML attributes that have the potential to execute unsafe JavaScript.

%w[onabort onafterprint onbeforeprint onbeforeunload onblur oncanplay oncanplaythrough onchange onclick oncontextmenu oncopy oncuechange oncut ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onfocus onhashchange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel onoffline ononline onpagehide onpageshow onpaste onpause onplay onplaying onpopstate onprogress onratechange onreset onresize onscroll onsearch onseeked onseeking onselect onstalled onstorage onsubmit onsuspend ontimeupdate ontoggle onunload onvolumechange onwaiting onwheel].to_h { [_1, true] }.freeze
UNBUFFERED_MUTEX =
Mutex.new

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Elements

register_element, register_void_element, registered_elements

Methods included from ElementClobberingGuard

method_added

Methods included from VoidElements

#area, #br, #col, #embed, #hr, #img, #input, #link, #meta, #param, #source, #track

Methods included from StandardElements

#a, #abbr, #address, #article, #aside, #audio, #b, #base, #bdi, #bdo, #blockquote, #body, #button, #canvas, #caption, #cite, #code, #colgroup, #data, #datalist, #dd, #del, #details, #dfn, #dialog, #div, #dl, #dt, #em, #fieldset, #figcaption, #figure, #footer, #form, #h1, #h2, #h3, #h4, #h5, #h6, #head, #header, #hgroup, #html, #i, #iframe, #ins, #kbd, #label, #legend, #li, #main, #map, #mark, #menu, #meter, #nav, #noscript, #object, #ol, #optgroup, #option, #output, #p, #picture, #portal, #pre, #progress, #q, #rp, #rt, #ruby, #s, #samp, #script, #search, #section, #select, #slot, #small, #span, #strong, #style, #sub, #summary, #sup, #table, #tbody, #td, #template_tag, #textarea, #tfoot, #th, #thead, #time, #title, #tr, #u, #ul, #var, #video, #wbr

Methods inherited from SGML

#__final_call__, #await, call, #call, #capture, #comment, #context, element_method?, #initialize, method_added, new, #plain, rendered_at_least_once!, #template, #unsafe_raw, #view_template, #whitespace

Constructor Details

This class inherits a constructor from Phlex::SGML

Class Method Details

.__unbuffered_class__Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
# File 'lib/phlex/html.rb', line 16

def __unbuffered_class__
	UNBUFFERED_MUTEX.synchronize do
		if defined? @unbuffered_class
			@unbuffered_class
		else
			@unbuffered_class = Class.new(Unbuffered)
		end
	end
end

Instance Method Details

#content_typeObject



59
60
61
# File 'lib/phlex/html.rb', line 59

def content_type
	"text/html"
end

#doctypeObject

Output an HTML doctype.



31
32
33
34
35
36
37
# File 'lib/phlex/html.rb', line 31

def doctype
	context = @_context
	return if context.fragments && !context.in_target_fragment

	context.buffer << "<!DOCTYPE html>"
	nil
end

#filenameObject



55
56
57
# File 'lib/phlex/html.rb', line 55

def filename
	nil
end

#svgnil

Outputs an ‘<svg>` tag



42
43
44
45
46
47
48
# File 'lib/phlex/html.rb', line 42

def svg(...)
	super do
		render Phlex::SVG.new do |svg|
			yield(svg)
		end
	end
end

#unbufferedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/phlex/html.rb', line 51

def unbuffered
	self.class.__unbuffered_class__.new(self)
end