Sha256: 3d7ffd12278edd04c671816d733ac9396eda0666ea807e8ac845c5f6fbcaf9f1

Contents?: true

Size: 690 Bytes

Versions: 1

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true

require 'gunter/view/json'
require 'gunter/view/text'

module Gunter
  # Gunter views module
  module Views
    class << self
      # Render templates
      # @example
      #   Gunter.render(:json, :templates, data)
      #
      # @param format [Symbol] the format to render
      # @param template [Symbol] the template to render
      # @param data [Hash] the data to render
      # @return [String] the rendered template
      def render(format, template, data)
        case format
        when :json
          Gunter::View::Json.send(template, data)
        else
          Gunter::View::Text.send(template, data)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gunter-0.1.0 lib/gunter/views.rb