Sha256: 330ae5ad2ec648e7b31895eaabc2f57e180076ba87467e294105891cc6dcf15c

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

require 'nano/string/camelize'

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

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.27.0 lib/nitro/helper/layout.rb