Sha256: c0b87632741aacdb9d2795dde0e30d9a1cd1bdaf8ccc33b768ae9add5f38573d

Contents?: true

Size: 906 Bytes

Versions: 6

Compression:

Stored size: 906 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)
    dom.at_css('html').add_child assets(:js)
    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

6 entries across 6 versions & 1 rubygems

Version Path
roda-component-0.1.11 test/dummy/components/layout.rb
roda-component-0.1.10 test/dummy/components/layout.rb
roda-component-0.1.9 test/dummy/components/layout.rb
roda-component-0.1.8 test/dummy/components/layout.rb
roda-component-0.1.7 test/dummy/components/layout.rb
roda-component-0.1.6 test/dummy/components/layout.rb