Sha256: 1811bc4a4919a9ac6e15b88cab37015079e99df1e5380be5364f7193c06c93b1

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

# -*- encoding : utf-8 -*-
module MustacheRender::CoreExt
  module BaseControllerExt
    def self.included(base)
      base.class_eval do
        helper HelperMethods

        extend   ClassMethods
        include InstanceMethods
      end
    end

    module SharedMethods
      def mustache_render template='', mustache={}
        result = ::MustacheRender::Mustache.render(template, mustache)
        impl_mustache_result_render result
      end

      def mustache_file_render template_path=nil, mustache={}
        result = ::MustacheRender::Mustache.file_render(template_path, mustache)
        impl_mustache_result_render result
      end

      #
      # 使用数据库中的模板进行渲染
      # - template_path: 模板的路径
      #
      def mustache_db_render(template_path=nil, mustache={})
        result = ::MustacheRender::Mustache.db_render(template_path, mustache)
        impl_mustache_result_render result
      end
    end

    module ClassMethods
    end

    module HelperMethods
      include SharedMethods

      private

      def impl_mustache_result_render(result)
        raw result
      end
    end

    module InstanceMethods
      include SharedMethods

      private

      def impl_mustache_result_render(result)
        render :text => result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mustache_render-0.0.12 lib/mustache_render/core_ext/base_controller_ext.rb
mustache_render-0.0.10 lib/mustache_render/core_ext/base_controller_ext.rb
mustache_render-0.0.9 lib/mustache_render/core_ext/base_controller_ext.rb
mustache_render-0.0.7 lib/mustache_render/core_ext/base_controller_ext.rb