Sha256: 2971bb499a8b07630e5d2f39b872a2a2994644ee27f5de6a9ae39d147402b5b2
Contents?: true
Size: 766 Bytes
Versions: 3
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true module Exclaim module Implementations INDENT = ' ' VBOX_COMPONENT = ->(config, env, &render_child) do first_line = '<div style="display: flex; flex-flow: column">' child_elements = (config['children'] || config['$vbox']).to_a child_lines = child_elements.flat_map do |child| result = render_child.call(child, env) result.lines.map { |line| "#{INDENT}#{line}" } end last_line = '</div>' # ensure each line ends with at least one newline to produce readable HTML lines = [first_line, *child_lines, last_line] lines.map { |line| line.end_with?("\n") ? line : "#{line}\n" }.join end VBOX_COMPONENT.define_singleton_method(:component?) { true } end end
Version data entries
3 entries across 3 versions & 1 rubygems