LowLoad is really dumb; like a bull in a china shop, smashing through fragile dependencies to autoload your code without manual load/require/require_relative calls.
- First LowLoad goes through all your files and notes their constant definitions
- Then it goes through the same files again and creates autoloads for those dependencies
- Then it goes through every file again and loads it into Ruby
This approach results in a very flexible autoloader with no conventions to follow, no internal dependency graph and very little configuration needed... just point it at a directory.
Features:
- Use any namespace structure you want (namespaces are not inferred from folder structure)
- Mix in manual requires in autoloaded files
- Supports RBX files
Load an .rb or .rbx file with:
LowLoad.lowload('spec/fixtures/html_node.rbx')Load an entire directory with:
LowLoad.dirload(File.expand_path('app', __FILE__))LowLoad supports normal Ruby (.rb) files as well as a few other embedded formats.
LowLoad supports loading RBX files (.rbx). RBX files are Ruby files containing unescaped HTML markup:
class MyClass
def render
<p>Hello</p>
end
endℹ️ For more information see LowNode.
Antlers syntax can be embedded inside the render method of your RBX file:
class ParentNode
def render
<p><{ ChildNode }></p>
end
endℹ️ For more information see Antlers.
- Folders are often organised by the kind of file it is, a bunch of views for example. But namespaces should be organised by your domain — different to your file structure
- You should be able to mix autoloading with manual
requireandrequire_relativecalls. You often need files outside the autoloaded directory
Like other autoloading libraries, LowLoad doesn't support circular dependencies on class load (runtime is fine).
❌ Please don't do:
class A
include B
end
class B
include A
end✅ Instead do:
class A
include C
end
class B
include C
end
class C
# Code that both A and B share.
endAdd gem 'lowload' to your Gemfile then:
bundle install