ERB::Rendering
Instance methods
Renders a compiled template method inside a swapped buffer —
used for layouts (content = view.__erb_render_action then
layout's yield returns it).
content_for/provide: store a named content block for the layout.
Macros
Same, but the method takes a block: layouts use <%= yield %> /
<%= yield :key %> to inject the action's content.
Compiles the class's partials and generates the runtime render
helpers. partials maps a partial name (as passed to render)
to a definition: path — the .erb file, locals — a
compile-time map of local variable name to its type:
compile_partials({ "post" => {path: "app/views/_post.html.erb", locals: {"post" => Post}}, })
dedent: true applies the compile-time dedent mode (see
compile_template) to every partial in the map.
Locals become real local variables inside the compiled method, so
templates reference them bare (<%= post.title %>), exactly like
Rails partials. Crystal forbids Object as a generic argument,
so the locals-hash value type is the union of all local types
(plus Int32 for the collection counter), deduplicated by name —
duplicate args inside Union(...) crash the compiler.
Compiles an ERB-syntax template into a method returning
SafeString. path is resolved from the compile-time working
directory (like stdlib ECR). dedent: true strips leading
whitespace of each line from literal text at compile time, so
indented sources render flat output (see template_processor.cr).
Crystal allows redefining a method — a duplicate name would silently shadow a handwritten helper (a runtime crash later, like a nil'd accessor), so collisions fail the build instead. Methods defined AFTER this macro call are not visible to the guard ({% @type.methods %} only sees the type so far).