
Issue #19458 has been updated by zverok (Victor Shepelev).
So what are you supposed to do if you wanted to include ERB in the string when you have to use ERB as the identifier?
This is a valid concern, and it doesn't have any good answer to it. On the other hand, 1. the possibility of a need to have a literal text `ERB`/`HTML`/`SQL`/`SLIM` _on a separate line_ in a HEREdoc presumably written in the corresponding language is relatively low ( 2. the feature of "there could be any text" was indeed introduced for a use cases you are describing, but its real usage for "tagging" strings is quite widespread; saying that it is no more significant than `"` vs `'` follows the original intention, but ignores the real usage (including in Ruby's standard library codebase, for example). 3. the usefulness of acknowledging "tagging" use in a language seems to be a least worth a discussion; whereupon the _harm_ of this idea seems to be quite low (other than the general opposition to change). ---------------------------------------- Feature #19458: Expose HEREDOC identifier https://bugs.ruby-lang.org/issues/19458#change-102058 * Author: joelhawksley (Joel Hawksley) * Status: Open * Priority: Normal ---------------------------------------- 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: ```ruby class Component erb_template <<~ERB <h1>Hello, <%= @name %>!</h1> ERB end ``` I'd prefer to be able to write: ```ruby 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) -- https://bugs.ruby-lang.org/