Sha256: 51ea5ac1091891ff400fd8150ecd2b8017c856b4ac79b5ad626f30e7d8eac08f

Contents?: true

Size: 633 Bytes

Versions: 3

Compression:

Stored size: 633 Bytes

Contents

module SectionsRails

  require "sections_rails/railtie" if defined?(Rails)
  
  def section name
    out = []
    out << javascript_include_tag("#{name}/#{name}") if File.exists? "#{Rails.root}/app/sections/#{name}/#{name}.js"
    out << stylesheet_link_tag("#{name}/#{name}") if File.exists? "#{Rails.root}/app/sections/#{name}/#{name}.css"
    if File.exists? "#{Rails.root}/app/sections/#{name}/_#{name}.html.erb" 
      out << render(:partial => "/../sections/#{name}/#{name}")
    else
      out << "<div class=\"#{name}\"></div>"
    end
    out.join("\n").html_safe
  end
  
end

ActionView::Base.send :include, SectionsRails

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sections_rails-0.0.4 lib/sections_rails.rb
sections_rails-0.0.3 lib/sections_rails.rb
sections_rails-0.0.2 lib/sections_rails.rb