Sha256: 518b8202831bca96f13d74c2c336156b39b297dc7e32ff1a48678918a3b46693

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

=begin
  parser/erb.rb - parser for ERB

  Copyright (C) 2005  Masao Mutoh
 
  You may redistribute it and/or modify it under the same
  license terms as Ruby.

  $Id: erb.rb,v 1.3 2006/01/07 13:39:13 mutoh Exp $
=end

require 'erb'
require 'gettext/parser/ruby.rb'

module GetText
  module ErbParser
    @config = {
      :extnames => ['.rhtml']
    }

    module_function
    def init(config)
      config.each{|k, v|
	@config[k] = v
      }
    end

    def parse(file, targets = [])
      erb = ERB.new(IO.readlines(file).join).src.split(/$/)
      RubyParser.parse_lines(file, erb, targets)
    end

    def target?(file)
      @config[:extnames].each do |v|
	return true if File.extname(file) == v
      end
      false
    end
  end
end

if __FILE__ == $0
  # ex) ruby glade.rhtml foo.rhtml  bar.rhtml
  ARGV.each do |file|
    p GetText::ErbParser.parse(file)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gettext-1.1.1-mswin32 lib/gettext/parser/erb.rb
gettext-1.1.1 lib/gettext/parser/erb.rb