Sha256: afbe41d9090fdcc3da7a8083d9115a7abcebf35d62eb8558def186ff0e37002d

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

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.4 2006/02/22 16:42:41 mutoh Exp $
=end

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

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

    module_function
    # Sets some preferences to parse ERB files.
    # * config: a Hash of the config. It can takes some values below:
    #   * :extnames: An Array of target files extension. Default is [".rhtml"].
    def init(config)
      config.each{|k, v|
	@config[k] = v
      }
    end

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

    def target?(file) # :nodoc:
      @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

18 entries across 18 versions & 1 rubygems

Version Path
gettext-1.10.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.9.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.8.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.7.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.6.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.5.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.4.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.3.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.2.0-mswin32 lib/gettext/parser/erb.rb
gettext-1.2.0 lib/gettext/parser/erb.rb
gettext-1.10.0 lib/gettext/parser/erb.rb
gettext-1.4.0 lib/gettext/parser/erb.rb
gettext-1.5.0 lib/gettext/parser/erb.rb
gettext-1.3.0 lib/gettext/parser/erb.rb
gettext-1.8.0 lib/gettext/parser/erb.rb
gettext-1.6.0 lib/gettext/parser/erb.rb
gettext-1.7.0 lib/gettext/parser/erb.rb
gettext-1.9.0 lib/gettext/parser/erb.rb