
Issue #20525 has been updated by bradgessler (Brad Gessler). Same reason you can conjure up a Proc via `-> {}` — the syntax looks cleaner and you don't have to stop and try to name it. Not having to name a string is a pretty big boost in terms staying in the flow. The second thing: it looks ugly having two of the same names by each other, which the original example shows: ``` markdown <<~MD # Hello How are you doing? MD ``` still looks kind of weird. This looks better: ``` markdown <<~ # Hello How are you doing?
----------------------------------------
Feature #20525: Percent string literal with indentation support or String#dedent
https://bugs.ruby-lang.org/issues/20525#change-109599
* Author: bradgessler (Brad Gessler)
* Status: Rejected
----------------------------------------
I have code that looks like this in an application:
```ruby
ContentSlide(title: "Why Phlex?"){
Markdown <<~MARKDOWN
* Because its fun
* Because its super-de-dooper
MARKDOWN
},
The "squiggle" HEREDOCs strips the indentation, but the name of the HEREDOC doesn't look that great since "Markdown" appears twice. What I'd prefer is a string literal that deals with indentation, maybe it looks something like this: ``` ContentSlide(title: "Why Phlex?"){ Markdown %~{ # Why do you like markdown? * Because its fun * Because its super-de-dooper } }, ``` If Ruby doesn't want to go down the path of adding another type of literal, I'd propose adding a method to String that does the same thing as the `~` HEREDOC so something like this is possible: ```ruby ContentSlide(title: "Why Phlex?"){ Markdown %{ # Why do you like markdown? * Because its fun * Because its super-de-dooper }.dedent }, ``` -- https://bugs.ruby-lang.org/