Sha256: 045a8ceac57dc1668b81e6b6d2b98e18efee85272620315230d2fdecd7b8e56f

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

module Vedeu

  # Provides means to use templates with Vedeu.
  module Templating

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

      include Vedeu::Templating::Helpers

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

      # Returns a new instance of Vedeu::Templating::Directive.
      #
      # @param code [String]
      # @return [Vedeu::Templating::Directive]
      def initialize(code)
        @code = code
      end

      # Evaluate the code/text in the template; converting any recognised
      # directives as they are encountered.
      #
      # @return [Vedeu::Stream]
      def process
        eval(code, proc {}.binding)
      end

      protected

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

    end # Directive

  end # Templating

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.60 lib/vedeu/templating/directive.rb
vedeu-0.4.59 lib/vedeu/templating/directive.rb
vedeu-0.4.58 lib/vedeu/templating/directive.rb
vedeu-0.4.57 lib/vedeu/templating/directive.rb