Module: Triplet::DSL
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper
- Included in:
- Template, ViewComponent
- Defined in:
- lib/triplet/dsl.rb
Constant Summary collapse
- TAGS =
[ :a, :abbr, :address, :area, :article, :aside, :audio, :b, :base, :bdi, :bdo, :blockquote, :body, :br, :button, :canvas, :caption, :cite, :code, :col, :colgroup, :data, :datalist, :dd, :del, :details, :dfn, :dialog, :div, :dl, :dt, :em, :embed, :fieldset, :figure, :footer, :form, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup, :hr, :html, :i, :iframe, :img, :input, :ins, :kbd, :keygen, :label, :legend, :li, :link, :main, :map, :mark, :menu, :menuitem, :meta, :meter, :nav, :noscript, :object, :ol, :optgroup, :option, :output, :p, :param, :pre, :progress, :q, :rb, :rp, :rt, :rtc, :ruby, :s, :samp, :script, :section, :select, :small, :source, :span, :strong, :style, :sub, :summary, :sup, :table, :tbody, :td, :template, :textarea, :tfoot, :th, :thead, :time, :title, :tr, :track, :u, :ul, :var, :video, :wbr ].freeze
- VOID_TAGS =
[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
Instance Method Summary collapse
Instance Method Details
#render_triplet(triplet) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/triplet/dsl.rb', line 44 def render_triplet(triplet) if triplet.is_a?(String) triplet elsif triplet.is_a?(Array) # If the array size is 3 and the first object is a # symbol, it's likely a renderable triplet if triplet.length == 3 && triplet[0].is_a?(Symbol) tag, attrs, children = triplet content_tag(tag, attrs) do if children.is_a?(Array) safe_join(children.map { |c| render_triplet(c) }, "") else render_triplet(children) end end else safe_join(triplet.map { |c| render_triplet(c) }, "") end else triplet.to_s end end |