Bakelite::Docs::C_DSL::MACROS_AND_VOLUMES
Compile-Time DSL and Volumes
Bakelite provides a declarative, type-safe macro DSL for embedding single files, folders, and custom volumes directly inside your Crystal application.
Executive Summary & Key Topics
| Topic | Method / Anchor | Description |
|---|---|---|
| Core Macro Directives | .topic_01_embedding_macros |
Syntax and options for bake and store macros. |
| Custom Volumes and Union Mounting | .topic_02_volume_management |
Isolating subsystems and layering assets by priority. |
Class methods
topic_01_embedding_macros
Core Macro Directives: Syntax and options for bake and store macros.
Include Bakelite::FS in your module or class to expose the DSL:
module AppAssets
include Bakelite::FS
# Direct inlined bake
bake "config/settings.yml", as_path: "settings.yml"
# Chunked streaming store
store "videos/intro.mp4", chunk_size: 131072, compress: :gzip
# Entire folder inlined
bake_folder "public/icons", prefix: "icons"
# Entire folder chunked
store_folder "assets/audio", prefix: "audio", chunk_size: 65536
end
topic_02_volume_management
Custom Volumes and Union Mounting: Isolating subsystems and layering assets by priority.
Volumes allow you to namespace assets, configure default compression and chunk size, and prioritize overlays (e.g. mods or DLC):
module AppAssets
include Bakelite::FS
volume :dlc, mount: "dlc", priority: 100 do
bake "dlc/extra_levels.json"
end
end
When querying paths via AppAssets["dlc/extra_levels.json"], the union router
automatically inspects mounted volumes in priority order, allowing higher-priority
volumes to shadow matching lower-priority files.