Module: HtmlSlice
- Defined in:
- lib/html_slice.rb,
lib/html_slice/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- TAGS =
%i[ div title embed meta br a em b i ul ol li img table tbody thead tr th td form input button link h1 h2 h3 h4 h5 h6 hr span label iframe template main footer aside source section small nav area ].freeze
- EMPTY_TAGS =
%i[ area br embed hr img input link meta source ].freeze
- TAGS_WITHOUT_HTML_ESCAPE =
%i[ style script ].freeze
- DEFAULT_SLICE =
:default- VERSION =
"0.2.2"
Instance Method Summary collapse
- #_(content) ⇒ Object
- #html_layout(html_slice_current_id = DEFAULT_SLICE, &block) ⇒ Object
- #html_slice(html_slice_current_id = DEFAULT_SLICE, wrap: ["", ""], &block) ⇒ Object
- #tag(tag_name, *args, &block) ⇒ Object
Instance Method Details
#_(content) ⇒ Object
57 58 59 60 |
# File 'lib/html_slice.rb', line 57 def _(content) ensure_html_slice @html_slice[@html_slice_current_id] << content.to_s end |
#html_layout(html_slice_current_id = DEFAULT_SLICE, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/html_slice.rb', line 25 def html_layout(html_slice_current_id = DEFAULT_SLICE, &block) html_slice( html_slice_current_id, wrap: ["<!DOCTYPE html><html>", "</html>"], &block ) end |
#html_slice(html_slice_current_id = DEFAULT_SLICE, wrap: ["", ""], &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/html_slice.rb', line 33 def html_slice(html_slice_current_id = DEFAULT_SLICE, wrap: ["", ""], &block) @html_slice_current_id = html_slice_current_id @html_slice ||= {} if block @html_slice[@html_slice_current_id] = wrap[0].dup instance_eval(&block) @html_slice[@html_slice_current_id] << wrap[1] end @html_slice[@html_slice_current_id] || "" end |
#tag(tag_name, *args, &block) ⇒ Object
62 63 64 65 |
# File 'lib/html_slice.rb', line 62 def tag(tag_name, *args, &block) content, attributes = parse_html_tag_arguments(args) generate_and_append_html_tag(tag_name, content, attributes, &block) end |