k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
980 stars 60 forks source link

Support of "annotate_template_file_names" or equivalent #180

Closed ghost closed 3 years ago

ghost commented 3 years ago

Recently in Rails 6.1 was introduced option to annotate rendering of templates with some debug comments. Internally such behavior is handled by actionview/lib/action_view/template/handlers/erb/erubi.rb:


if ActionView::Base.annotate_template_file_names
  properties[:preamble]   = "@output_buffer.safe_append='<!-- BEGIN #{properties[:short_identifier]} -->\n';"
  properties[:postamble]  = "@output_buffer.safe_append='<!-- END #{properties[:short_identifier]} -->\n';@output_buffer.to_s"
else
  properties[:preamble]   = ""
  properties[:postamble]  = "@output_buffer.to_s"
end

https://github.com/rails/rails/pull/38848 That's very useful developer-time-saving feature, especially on projects with complex layouts.

Is there any way to enable behavior like this in hamlit? (register callback, additional prefix handler, etc)

k0kubun commented 3 years ago

Done. Please try v2.14.5.

ghost commented 3 years ago

@k0kubun , just updated gem. Works perfectly. That's awesome! Thank you very much. 🎂