Sha256: 293b9d168b586c02d2766123843cc5ecd07a2c03979d4b24b767a0d11d379161

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

module Optimacms
      module Mycontroller
      #extend ActiveSupport::Concern

      #included do
      #  before_filter :my_set_render
      #end

      def my_set_render
        @is_optimacms = true

      end

      def default_render(*args)
        if self.controller_name!='pages' && !@optimacms_tpl.nil? && @is_optimacms
          render @optimacms_tpl, :layout=>@optimacms_layout and return
          #(render :text => "hello", :layout => @optimacms_layout) and return

          # http://stackoverflow.com/questions/21129587/ruby-on-rails-how-to-render-file-as-plain-text-without-any-html
          #render :plain will set the content type to text/plain
          #render :html will set the content type to text/html
          #render :body will not set the content type header.
          # render text: "some text". :plain does not work.
        end

        super
      end

      def my_set_render_template(tpl_view, tpl_layout)
        @optimacms_tpl = tpl_view
        @optimacms_layout = tpl_layout
      end

      def my_set_meta(meta)
        @optimacms_meta_title = meta[:title]
        @optimacms_meta_keywords = meta[:keywords]
        @optimacms_meta_description = meta[:description]
      end

    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
optimacms-0.1.15 lib/optimacms/mycontroller.rb
optimacms-0.1.14 lib/optimacms/mycontroller.rb
optimacms-0.1.5 lib/optimacms/mycontroller.rb
optimacms-0.1.3 lib/optimacms/mycontroller.rb
optimacms-0.1.2 lib/optimacms/mycontroller.rb
optimacms-0.1.1 lib/optimacms/mycontroller.rb