diff --git a/lib/haml.rb b/lib/haml.rb index a7f2a5e85..04f473d12 100644 --- a/lib/haml.rb +++ b/lib/haml.rb @@ -1,13 +1,14 @@ # frozen_string_literal: true -require 'haml/engine' -require 'haml/error' -require 'haml/version' -require 'haml/template' +require_relative 'haml/engine' +require_relative 'haml/error' +require_relative 'haml/version' +require_relative 'haml/template' if File.basename($0) != 'haml' begin require 'rails' - require 'haml/railtie' + + require_relative 'haml/railtie' rescue LoadError end end diff --git a/lib/haml/attribute_builder.rb b/lib/haml/attribute_builder.rb index fb3271e09..4aa0c3802 100644 --- a/lib/haml/attribute_builder.rb +++ b/lib/haml/attribute_builder.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/object_ref' +require_relative 'object_ref' module Haml::AttributeBuilder class << self diff --git a/lib/haml/attribute_compiler.rb b/lib/haml/attribute_compiler.rb index 610cff696..cb9f107d6 100644 --- a/lib/haml/attribute_compiler.rb +++ b/lib/haml/attribute_compiler.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'haml/attribute_builder' -require 'haml/attribute_parser' -require 'haml/ruby_expression' +require_relative 'attribute_builder' +require_relative 'attribute_parser' +require_relative 'ruby_expression' module Haml # The list of boolean attributes. You may add custom attributes to this constant. diff --git a/lib/haml/attribute_parser.rb b/lib/haml/attribute_parser.rb index 8476e1bc4..3e026da00 100644 --- a/lib/haml/attribute_parser.rb +++ b/lib/haml/attribute_parser.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/ruby_expression' +require_relative 'ruby_expression' module Haml class AttributeParser diff --git a/lib/haml/cli.rb b/lib/haml/cli.rb index 551d0004b..2ec779008 100644 --- a/lib/haml/cli.rb +++ b/lib/haml/cli.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require 'haml' +require_relative '../haml' + require 'thor' module Haml @@ -76,7 +77,9 @@ def generate_code(file) if options[:actionview] require 'action_view' require 'action_view/base' - require 'haml/rails_template' + + require_relative 'rails_template' + handler = Haml::RailsTemplate.new template = ActionView::Template.new(template, 'inline template', handler, { locals: [] }) code = handler.call(template) diff --git a/lib/haml/compiler.rb b/lib/haml/compiler.rb index 51b22d4c4..735a0956f 100644 --- a/lib/haml/compiler.rb +++ b/lib/haml/compiler.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require 'haml/compiler/children_compiler' -require 'haml/compiler/comment_compiler' -require 'haml/compiler/doctype_compiler' -require 'haml/compiler/script_compiler' -require 'haml/compiler/silent_script_compiler' -require 'haml/compiler/tag_compiler' -require 'haml/filters' -require 'haml/identity' +require_relative 'compiler/children_compiler' +require_relative 'compiler/comment_compiler' +require_relative 'compiler/doctype_compiler' +require_relative 'compiler/script_compiler' +require_relative 'compiler/silent_script_compiler' +require_relative 'compiler/tag_compiler' +require_relative 'filters' +require_relative 'identity' module Haml class Compiler diff --git a/lib/haml/compiler/children_compiler.rb b/lib/haml/compiler/children_compiler.rb index a3a06ab21..2e492874c 100644 --- a/lib/haml/compiler/children_compiler.rb +++ b/lib/haml/compiler/children_compiler.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/temple_line_counter' +require_relative '../temple_line_counter' module Haml class Compiler diff --git a/lib/haml/compiler/script_compiler.rb b/lib/haml/compiler/script_compiler.rb index dc1b18269..db0b8fcc6 100644 --- a/lib/haml/compiler/script_compiler.rb +++ b/lib/haml/compiler/script_compiler.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true require 'temple/static_analyzer' -require 'haml/ruby_expression' -require 'haml/string_splitter' + +require_relative '../ruby_expression' +require_relative '../string_splitter' module Haml class Compiler diff --git a/lib/haml/compiler/tag_compiler.rb b/lib/haml/compiler/tag_compiler.rb index 89dc3b4af..5f42eae79 100644 --- a/lib/haml/compiler/tag_compiler.rb +++ b/lib/haml/compiler/tag_compiler.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'haml/util' -require 'haml/attribute_compiler' -require 'haml/string_splitter' +require_relative '../util' +require_relative '../attribute_compiler' +require_relative '../string_splitter' module Haml class Compiler diff --git a/lib/haml/engine.rb b/lib/haml/engine.rb index 6031f43ee..929452788 100644 --- a/lib/haml/engine.rb +++ b/lib/haml/engine.rb @@ -1,15 +1,16 @@ # frozen_string_literal: true require 'temple' -require 'haml/parser' -require 'haml/compiler' -require 'haml/html' -require 'haml/string_splitter' -require 'haml/escape' -require 'haml/escape_any' -require 'haml/force_escape' -require 'haml/dynamic_merger' -require 'haml/ambles' -require 'haml/whitespace' + +require_relative 'parser' +require_relative 'compiler' +require_relative 'html' +require_relative 'string_splitter' +require_relative 'escape' +require_relative 'escape_any' +require_relative 'force_escape' +require_relative 'dynamic_merger' +require_relative 'ambles' +require_relative 'whitespace' module Haml class Engine < Temple::Engine diff --git a/lib/haml/escape.rb b/lib/haml/escape.rb index 74e41cda2..b76bb61fc 100644 --- a/lib/haml/escape.rb +++ b/lib/haml/escape.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/util' +require_relative 'util' module Haml class Escape < Temple::Filters::Escapable diff --git a/lib/haml/escape_any.rb b/lib/haml/escape_any.rb index 6eb613f52..24a864d95 100644 --- a/lib/haml/escape_any.rb +++ b/lib/haml/escape_any.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/escape' +require_relative 'escape' module Haml # This module allows Temple::Filter to dispatch :fescape on `#compile`. diff --git a/lib/haml/filters.rb b/lib/haml/filters.rb index 9d91a5808..982e09326 100644 --- a/lib/haml/filters.rb +++ b/lib/haml/filters.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'haml/filters/base' -require 'haml/filters/text_base' -require 'haml/filters/tilt_base' -require 'haml/filters/coffee' -require 'haml/filters/css' -require 'haml/filters/erb' -require 'haml/filters/escaped' -require 'haml/filters/javascript' -require 'haml/filters/less' -require 'haml/filters/markdown' -require 'haml/filters/plain' -require 'haml/filters/preserve' -require 'haml/filters/ruby' -require 'haml/filters/sass' -require 'haml/filters/scss' -require 'haml/filters/cdata' +require_relative 'filters/base' +require_relative 'filters/text_base' +require_relative 'filters/tilt_base' +require_relative 'filters/coffee' +require_relative 'filters/css' +require_relative 'filters/erb' +require_relative 'filters/escaped' +require_relative 'filters/javascript' +require_relative 'filters/less' +require_relative 'filters/markdown' +require_relative 'filters/plain' +require_relative 'filters/preserve' +require_relative 'filters/ruby' +require_relative 'filters/sass' +require_relative 'filters/scss' +require_relative 'filters/cdata' module Haml class Filters diff --git a/lib/haml/filters/base.rb b/lib/haml/filters/base.rb index 4d344ef07..319740f63 100644 --- a/lib/haml/filters/base.rb +++ b/lib/haml/filters/base.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/util' +require_relative '../util' module Haml class Filters diff --git a/lib/haml/filters/plain.rb b/lib/haml/filters/plain.rb index 16e8abbb6..ddc8a8952 100644 --- a/lib/haml/filters/plain.rb +++ b/lib/haml/filters/plain.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/string_splitter' +require_relative '../string_splitter' module Haml class Filters diff --git a/lib/haml/force_escape.rb b/lib/haml/force_escape.rb index 9288dc056..07b1d8343 100644 --- a/lib/haml/force_escape.rb +++ b/lib/haml/force_escape.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -require 'haml/escape' +require_relative 'escape' module Haml # This module allows Temple::Filter to dispatch :fescape on `#compile`. diff --git a/lib/haml/parser.rb b/lib/haml/parser.rb index 3357bb0eb..85659ad4a 100644 --- a/lib/haml/parser.rb +++ b/lib/haml/parser.rb @@ -2,8 +2,9 @@ require 'ripper' require 'strscan' -require 'haml/error' -require 'haml/util' + +require_relative 'error' +require_relative 'util' module Haml class Parser diff --git a/lib/haml/rails_helpers.rb b/lib/haml/rails_helpers.rb index c92b55107..b0533d7f5 100644 --- a/lib/haml/rails_helpers.rb +++ b/lib/haml/rails_helpers.rb @@ -1,5 +1,5 @@ # frozen_string_literal: false -require 'haml/helpers' +require_relative 'helpers' # There are only helpers that depend on ActionView internals. module Haml diff --git a/lib/haml/rails_template.rb b/lib/haml/rails_template.rb index 30d74691c..cd97ac265 100644 --- a/lib/haml/rails_template.rb +++ b/lib/haml/rails_template.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require 'temple' -require 'haml/engine' -require 'haml/rails_helpers' -require 'haml/util' + +require_relative 'engine' +require_relative 'rails_helpers' +require_relative 'util' module Haml class RailsTemplate diff --git a/lib/haml/railtie.rb b/lib/haml/railtie.rb index faeb55063..a737a995b 100644 --- a/lib/haml/railtie.rb +++ b/lib/haml/railtie.rb @@ -4,7 +4,7 @@ module Haml class Railtie < ::Rails::Railtie initializer :haml, before: :load_config_initializers do |app| - require 'haml/rails_template' + require_relative 'rails_template' end end end diff --git a/lib/haml/template.rb b/lib/haml/template.rb index 2e4f7cc99..f75fed1f8 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -1,7 +1,8 @@ # frozen_string_literal: false require 'temple' -require 'haml/engine' -require 'haml/helpers' + +require_relative 'engine' +require_relative 'helpers' module Haml Template = Temple::Templates::Tilt.create(