Sha256: f48422665529346919577cfedb2946a710e8ee592b4040114cd0952346d85d83

Contents?: true

Size: 915 Bytes

Versions: 38

Compression:

Stored size: 915 Bytes

Contents

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

      def mount!
        # nothing, but keep it for compatibility with browser
      end

      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

38 entries across 38 versions & 1 rubygems

Version Path
isomorfeus-preact-10.6.25 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.24 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.23 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.22 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.21 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.20 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.19 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.18 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.17 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.16 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.15 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.14 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.13 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.12 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.11 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.10 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.9 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.8 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.7 lib/isomorfeus/top_level_ssr.rb
isomorfeus-preact-10.6.6 lib/isomorfeus/top_level_ssr.rb