Sha256: ce09180cc77b8555bf5aebdc0f38eb2101853225e0f67d4a78f2361204611316

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

module Knitkit
  class SyntaxValidator
    class << self

      def validate_content(file_type, content)
        case file_type.to_sym
        when :erb
          validate_erb(content)
        else
          return nil
        end
      end

      def validate_file(file)
        #stubbed for later development
      end

      private

      def validate_erb(contents)
        begin
          ActionView::Template::Handlers::Erubis.new(contents).result
        rescue SyntaxError=> ex
          ex.message
        rescue => ex
          nil
        end
      end

    end
  end#SyntaxValidator
end#Knitkit

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knitkit-3.2.0 lib/knitkit/syntax_validator.rb
knitkit-3.0.0 lib/knitkit/syntax_validator.rb