Project

General

Profile

Actions

Feature #19458

open

Expose HEREDOC identifier

Added by joelhawksley (Joel Hawksley) about 1 year ago. Updated 10 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:112538]

Description

I’d like to have access to the HEREDOC identifier.

In the ViewComponent framework I help maintain, we added a method to declare a template as such:

class Component
  erb_template <<~ERB
    <h1>Hello, <%= @name %>!</h1>
  ERB
end

I'd prefer to be able to write:

class Component
  template <<~ERB
    <h1>Hello, <%= @name %>!</h1>
  ERB
end

And be able to see that the argument passed to .template was from a HEREDOC with an ERB identifier, which would allow me to use the correct template handler to compile the template.

I could see this being implemented:

  1. As a new property of String, such as identifier or heredoc_identifier.
  2. By having HEREDOCs return a subclass of String that includes an identifier property.

I'd be happy to work on implementing this change.


Files

clipboard-202302251947-5owjc.png (16.4 KB) clipboard-202302251947-5owjc.png zverok (Victor Shepelev), 02/25/2023 05:47 PM
Actions

Also available in: Atom PDF

Like2
Like0Like0Like0Like0Like1Like0Like0Like0Like0Like0Like0