Sha256: 94cbd325f81468b0e8ba2f4184ae56607249cad4fe36a999571fbea7c6a47d41

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

require "erb"

module Rubysmith
  module Renderers
    # Renders ERB templates as fully functional files.
    class ERB
      def initialize configuration,
                     scope: Renderers::Namespace.new(configuration.project_class),
                     client: ::ERB
        @configuration = configuration
        @scope = scope
        @client = client
      end

      def call(content) = client.new(content, trim_mode: "<>", eoutvar: "@buffer").result(binding)

      private

      attr_accessor :buffer
      attr_reader :configuration, :scope, :client

      def namespace = self.buffer = scope.call(yield)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysmith-0.11.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.10.0 lib/rubysmith/renderers/erb.rb