Sha256: 0ca48afb4b35dfed66fd1082999096948f6e799f0c01d17842d918e3a7f107ec

Contents?: true

Size: 821 Bytes

Versions: 8

Compression:

Stored size: 821 Bytes

Contents

module Isomorfeus
  class TopLevel
    class << self
      attr_accessor :ssr_route_path
      attr_accessor :transport_ws_url

      def render_component_to_string(component_name, props)
        component = nil
        %x{
          if (typeof component_name === 'string' || component_name instanceof String) {
            component = component_name.split(".").reduce(function(o, x) {
              return (o !== null && typeof o[x] !== "undefined" && o[x] !== null) ? o[x] : null;
            }, Opal.global)
          } else {
            component = component_name;
          }
        }
        component = Isomorfeus.cached_component_class(component_name) unless component
        Preact.render_to_string(Preact.create_element(component, `Opal.Hash.$new(props)`))
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
isomorfeus-preact-10.6.44 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.43 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.42 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.41 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.40 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.39 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.38 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.37 lib/isomorfeus/top_level_ssr.rb