Sha256: b3ab51d380901c296a0a55197133efd14df96f3c65beb78977052f4595911579
Contents?: true
Size: 648 Bytes
Versions: 10
Compression:
Stored size: 648 Bytes
Contents
# frozen_string_literal: true require "tilt/jbuilder" module Mihari module Services # # Jbuilder based JSON renderer # class JbuilderRenderer < Service attr_reader :template # # @param [String] template # @param [Hash] params # # @return [String] # def call(template, params = {}) @template = template jbuilder_template = Tilt::JbuilderTemplate.new { template_string } jbuilder_template.render(nil, params) end def template_string return File.read(template) if Pathname(template).exist? template end end end end
Version data entries
10 entries across 10 versions & 1 rubygems