Sha256: aa85f71154c1c18dab5295befd64c2b4376440fc15409c502a9edbdcf121b3d4

Contents?: true

Size: 798 Bytes

Versions: 3

Compression:

Stored size: 798 Bytes

Contents

module Vedeu

  module Templating

    # Converts a directive found in a template into a Vedeu::Stream object.
    #
    # @api private
    class Directive

      include Vedeu::Templating::Helpers

      # @param code [String]
      # @return [Vedeu::Stream]
      def self.process(code)
        new(code).process
      end

      # @param code [String]
      # @return [Vedeu::Templating::Directive]
      def initialize(code)
        @code = code
      end

      # @return [Vedeu::Stream]
      def process
        eval(code, proc.binding)
      end

      protected

      # @!attribute [r] code
      # @return [String]
      attr_reader :code

      private

      # @return [Proc]
      def proc
        @proc ||= Proc.new {}
      end

    end # Directive

  end # Templating

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.4.35 lib/vedeu/templating/directive.rb
vedeu-0.4.34 lib/vedeu/templating/directive.rb
vedeu-0.4.33 lib/vedeu/templating/directive.rb