Plugin Reference
HamlPlugin
HamlPlugin turns `.haml` files into Ruby component classes with imports, source maps, companion styles, and optional translations.
Component Output
A Haml module exports a component class as Default. The generated class inherits from the configured component base class and renders through the configured factory.
Klenod::Build::Plugins::HamlPlugin.new(
component_base_class: "Example::Component",
factory: "Example::H",
global_variables: "@__props",
i18n_class: "Example::I18n"
)
Imported component constants can be used directly as Haml tags. %Button compiles to a factory call using the imported component class as the tag. Imported TSX custom element descriptors from JavaScriptPlugin can also be used as tags, letting Haml render browser custom elements without repeating their generated tag names.
Prop Globals
global_variables is optional. When configured, Haml Ruby code rewrites application-style global variable reads to lookups on that Ruby expression.
%h1= $title
%p= $summary
With global_variables: "@__props", the generated Ruby reads @__props[:title] and @__props[:summary]. The example framework sets @__props before component initialization, so templates and initializers can read props consistently.
Built-in Ruby globals are preserved. $!, $1, $LOAD_PATH, and other special globals keep their normal Ruby meaning.
Ruby Blocks And Filters
Top-level :ruby defines imports, constants, and methods on the generated component class. Later Ruby script blocks compile into the render method, where request-local helpers from the application framework are available.
= prints a value, - runs code silently, and printed Ruby blocks such as = if condition render their Haml body.
Haml :markdown filters are delegated to MarkdownPlugin. Haml :css filters become inline CSS sources collected from the template.
Companions
Haml automatically watches and imports matching CSS companions as ClassNames. The companion CSS uses the normal Ruby/Haml CSS path, so class and tag selectors are scoped through CSSPlugin.
components/Card.haml
components/Card.css
routes/docs/+page.haml
routes/docs/+page.css
Translation companions use IntlPlugin. Haml can run without IntlPlugin; in that case the generated component receives an empty translation map.
components/Card.intl.en.toml
components/Card.intl.sv.toml
i18n_class is optional. When configured, every generated component gets an I18n constant initialized with the component class:
I18n = Example::I18n.new(self)
i18n_constant can override the constant name. If omitted, it defaults to I18n.
Errors
Generated Ruby includes source map marks. Runtime backtraces can be rewritten to original Haml files and parse errors show Haml source context without requiring users to inspect generated Ruby. CSS companions and inline CSS filters keep their own source maps, so stylesheet errors and browser source maps point back to the original source where possible.