Sha256: bc9a6cfb38e3f6fd8585cb9279cb7fa51553f27fedebfcfa8653bb223e431bd2

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.41.0 lib/nitro/helper/layout.rb
nitro-0.40.0 lib/nitro/helper/layout.rb