Sha256: fdefc09270514a156b4f3811661b07874615ad8a7238056990cede95440cedb7

Contents?: true

Size: 476 Bytes

Versions: 4

Compression:

Stored size: 476 Bytes

Contents

# frozen_string_literal: true

module Troy
  class EmbeddedRuby
    # The template content.
    #
    attr_reader :content

    # The data that must be rendered within
    # the Troy::Context object.
    #
    attr_reader :data

    def initialize(content, data)
      @content = content
      @data = data
    end

    def context
      @context ||= Context.new(data).extend(Helpers)
    end

    def render
      ERB.new(content).result context.to_binding
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troy-0.0.39 lib/troy/embedded_ruby.rb
troy-0.0.38 lib/troy/embedded_ruby.rb
troy-0.0.37 lib/troy/embedded_ruby.rb
troy-0.0.36 lib/troy/embedded_ruby.rb