Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 756 Bytes

23-embed.md

File metadata and controls

30 lines (20 loc) · 756 Bytes

File Embedding

Embed file contents into your binary at compile time with embed:

embed "config.yaml" as config
puts config

The file is read during compilation and baked into the executable. No external files needed at runtime.

Multiple embeds

embed "header.html" as header
embed "footer.html" as footer

puts header + content + footer

Path rules

Paths are relative to the source file. Files must be in the same directory or a subdirectory — you cannot use ../ to escape:

embed "assets/logo.txt" as logo     # OK
embed "../secret.txt" as secret     # ERROR: escapes source directory

This mirrors Go's embed restriction and prevents libraries from accessing files outside their own directory tree.