module GettextI18nRailsJs::Parser::Handlebars

Public Instance Methods

target?(file) click to toggle source
# File lib/gettext_i18n_rails_js/parser/handlebars.rb, line 35
def target?(file)
  [
    /\.handlebars\Z/,
    /\.handlebars.erb\Z/,
    /\.hbs\Z/,
    /\.hbs.erb\Z/,
    /\.mustache\Z/,
    /\.mustache.erb\Z/
  ].any? { |regexp| file.match regexp }
end

Protected Instance Methods

collect_for(value) { |function, arguments, 1| ... } click to toggle source
# File lib/gettext_i18n_rails_js/parser/handlebars.rb, line 48
def collect_for(value)
  ::File.read(
    value
  ).scan(invoke_regex).collect do |_whole, function, arguments|
    yield(function, arguments, 1)
  end.compact
end
invoke_regex() click to toggle source
# File lib/gettext_i18n_rails_js/parser/handlebars.rb, line 56
def invoke_regex
  #
  # * Matches the function handlebars helper call grouping "{{"
  # * A parenthesis to start the arguments to the function
  # * Then double quote string
  # * Remaining arguments
  # * Function call closing parenthesis
  #

  /
    \B[{]{2}(
      ([snN]?#{gettext_function})
      \s+
      (
        ".*?"
        .*?
      )
    )
    [}]{2}
  /x
end