Sha256: 27607bd1a31531365c8a63a5f9ca99b4efec5e944868174458b1f1a11ca53b16

Contents?: true

Size: 929 Bytes

Versions: 37

Compression:

Stored size: 929 Bytes

Contents

class LayoutComp < Roda::Component
  comp_name :layout
  comp_html "../public/chat/index.html"
  comp_setup do |dom|
    # remove hard coded links as we are adding them in using the assets plugin.
    dom.css('head > link').remove
    # add require css and javascript
    dom.at_css('head').add_child assets([:css, :chat])
    dom.at_css('html').add_child assets([:js, :chat])
    dom.at_css('html').add_child <<-EOF
      <script type="text/javascript" src="/assets/components/roda/component.js"></script>
      <script type="text/javascript" src="/faye/client.js"></script>
    EOF
  end

  def display data = {}, &block
    if server?
      body_class = data.delete :body_class

      # we need this so that roda-components can authenticate your sessions
      dom.at_css('head').add_child csrf_metatag

      dom.find('body').html(yield)

      dom.at('body')['class'] = body_class if body_class

      dom
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
roda-component-0.1.73 test/dummy/components/layout.rb
roda-component-0.1.72 test/dummy/components/layout.rb
roda-component-0.1.71 test/dummy/components/layout.rb
roda-component-0.1.70 test/dummy/components/layout.rb
roda-component-0.1.69 test/dummy/components/layout.rb
roda-component-0.1.68 test/dummy/components/layout.rb
roda-component-0.1.67 test/dummy/components/layout.rb
roda-component-0.1.66 test/dummy/components/layout.rb
roda-component-0.1.65 test/dummy/components/layout.rb
roda-component-0.1.64 test/dummy/components/layout.rb
roda-component-0.1.63 test/dummy/components/layout.rb
roda-component-0.1.62 test/dummy/components/layout.rb
roda-component-0.1.61 test/dummy/components/layout.rb
roda-component-0.1.60 test/dummy/components/layout.rb
roda-component-0.1.59 test/dummy/components/layout.rb
roda-component-0.1.58 test/dummy/components/layout.rb
roda-component-0.1.57 test/dummy/components/layout.rb
roda-component-0.1.56 test/dummy/components/layout.rb
roda-component-0.1.55 test/dummy/components/layout.rb
roda-component-0.1.54 test/dummy/components/layout.rb