🧐 What is Loco-Rails-Core?
Loco-Rails-Core is a Rails plugin that has been extracted from Loco-Rails. The reason for this extraction was to pull out functionality that can be used as a stand-alone lib. This functionality was the origin of the Loco-Rails project.
Loco-Rails-Core's single generator adds
Loco::Core::Helpers module to
It also updates the
application.html.erb layout by adding
data-* attributes to HTML
Loco-Rails-Core does this via methods defined in the mentioned above
Given that the
index action from
Main::PagesControllers handles a given request.
<body>'s data attributes are gonna look like this:
<body data-namespace="Main" data-controller="Pages" data-action="index"> </body>
Loco-JS-Core will act similarly (simplified version):
If you don't define a namespace controller - it will be skipped.
If you don't define an
index actions - Loco-JS-Core won't call them.
Loco-Rails-Core is the right choice if you don't need all features that Loco-Rails provides.
Add this line to your application's Gemfile:
And then execute:
$ bin/rails generate loco:core:file_injector
The gem is available as open source under the terms of the MIT License.
Zbigniew Humeniuk from Art of Code