Sha256: ac0f91de912bf3ebf17161c191fad634035c1838d281807cbd31a3ec9f0bb3ef

Contents?: true

Size: 706 Bytes

Versions: 8

Compression:

Stored size: 706 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 = block_given? ? scope.call(yield) : buffer + scope.call
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubysmith-1.1.0 lib/rubysmith/renderers/erb.rb
rubysmith-1.0.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.16.1 lib/rubysmith/renderers/erb.rb
rubysmith-0.16.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.15.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.14.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.13.0 lib/rubysmith/renderers/erb.rb
rubysmith-0.12.0 lib/rubysmith/renderers/erb.rb