Sha256: c9ec20bd4baf2e8b1f87f17401660e5dd394106e78a51ab27297ed469f38a38c

Contents?: true

Size: 896 Bytes

Versions: 4

Compression:

Stored size: 896 Bytes

Contents

require 'facet/inflect'

require 'nitro/element'

module Nitro

# This helper uses Nitro's powerfull Elements mechanism to
# implement a simple Rails style Layout helper. Perhaps this
# may be useful for people coming over from Rails.
#
# WARNING: This is not enabled by default. You have to insert
# the LayoutCompiler before the ElementsCompiler for layout to
# work.

module LayoutHelper

  def self.included(base)
    base.module_eval do    
      # Enclose all templates of this controller with the
      # given element.
      
      def self.layout(name = nil)
        klass = name.to_s.camelize
        
        unless klass
          if defined? 'Nitro::Element::Layout'
            klass = Nitro::Element::Layout
          end
        end
        
        if klass
          ann self, :layout => klass
        end
      end
    end
  end

end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nitro-0.28.0 lib/nitro/helper/layout.rb
nitro-0.29.0 lib/nitro/helper/layout.rb
nitro-0.30.0 lib/nitro/helper/layout.rb
nitro-0.31.0 lib/nitro/helper/layout.rb