module Quince
Constants
- VERSION
Attributes
middleware[R]
underlying_app[RW]
Public Class Methods
define_constructor(const, constructor_name = const.to_s)
click to toggle source
# File lib/quince/singleton_methods.rb, line 25 def define_constructor(const, constructor_name = const.to_s) HtmlTagComponents.instance_eval do define_method(constructor_name) do |*children, **props, &block_children| new_props = { **props, Quince::Component::HTML_SELECTOR_ATTR => __id } const.create(*children, **new_props, &block_children) end end end
middleware=(middleware)
click to toggle source
# File lib/quince/singleton_methods.rb, line 10 def middleware=(middleware) @middleware = middleware Object.define_method(:expose) do |component, at:| Quince.middleware.create_route_handler( verb: :GET, route: at, ) do |params| component = component.create if component.instance_of? Class Quince::Component.class_variable_set :@@params, params component end end Object.send :private, :expose end
optional_string()
click to toggle source
# File lib/quince/singleton_methods.rb, line 6 def optional_string @optional_string ||= Rbs("String?") end
to_html(component)
click to toggle source
# File lib/quince/singleton_methods.rb, line 34 def to_html(component) output = component until output.is_a? String case output when Array output = output.map { |c| to_html(c) }.join when String break when Proc output = to_html(output.call) when NilClass output = "" else tmp = output output = output.render if output.is_a?(Array) raise "#render in #{tmp.class} should not return multiple elements. Consider wrapping it in a div" end end end output end