Skip to content

crails-framework/crails-assets

Repository files navigation

crails-assets

Asset pipeline for the Crails Framework.

Versioned files

Useful to avoid caching issues and to work with CDNs, crails-assets adds a checksum at the end of your filenames, to identify each single version of your assets.

Compiler-safe

crails-assets maps all your assets within lib/assets.hpp. You can then reference the public path of each asset using their alias in the Assets namespace. Assuming a project with two assets stored as /assets/application.scss and /assets/images/homepage.png, here's how you would include these assets in your web pages:

<html>
  <head>
    <%= tag("link", {{"href", Assets::application_scss}, {"rel", "stylesheet"}) %>
  </head>
  <body>
    <%= tag("img", {{"src", Assets::images_homepage_png}} %>
  </body>
</html>

Aliases are generated by taking the local path of an asset, and replacing any character that would be invalid in a C++ variable name with an underscore.

Using crails-asset, your compiler will protect you against spelling issues, or the removal of assets that are still being used by your projects.

Compression

To speed up page loading, you're expected to provide compressed files for your assets. Crails-asset will compress each of your asset using gzip, brotli, or both.

Sass

CSS will be generated from Sass and SCSS stylesheets, as long as an implementation of sass is installed on your system. Currently, scss and node-sass are supported (provided respectively by rubygems and nodejs).

asset_path

When referencing your own assets, you can use asset_path(path-to-file.jpg), and crails-asset will replace this pattern with the public url for said asset.

Paths given to asset_path must always be relative to crails-assets' input path option.

About

asset pipeline for the crails framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published