Posted almost 6 years ago. Visible to the public.

Get compiled code of a view template in Rails 4.2

If you want to inspect the compiled code of your erb (or haml) templates, you can run the following code in your view or your controller:

Copy
template = lookup_context.find_template(action_name, lookup_context.prefixes) template.handler.call(template.refresh(self))

The output will be something like

Copy
@output_buffer = output_buffer || ActionView::OutputBuffer.new;@output_buffer.safe_append='My template '.freeze;@output_buffer.to_s

Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.

Join our free training event and learn to fix any flaky test suite, even in large legacy applications.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
almost 6 years ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more