module

Hecr::Compiler::HeredocFormatter

Formats hecr templates embedded in Crystal source as raw heredocs — the inline authoring mode (Hecr.render <<-'HECR'). The counterpart of HEEx's ~H-sigil formatting in the mix format plugin.

Detection is the documented convention, not Crystal parsing: a line containing <<-'HECR' (outside a # comment) opens a template; the body runs until the line whose content is exactly HECR, whose indentation is the heredoc's strip margin (Crystal <<- semantics). The body is dedented, formatted with Formatter, and re-indented. Non-template heredocs should simply use another delimiter.

Constants

DELIMITER = "HECR"
OPENER = "<<-'HECR'"

Instance methods

format(source : String, file : String = "nofile", line_length : Int32 = 98) : String
Source