Feature #15538
closedErb indenting / unindenting
Description
In Erb, would it be possible to add a new tag that would indent the following content to match the depth of the tag? The tag could be <%~ (to resemble the <<~EOS squiggy heredoc).
Reason¶
Something like this would be easy to follow:
But unfortunately it will render with "extra" indentation:
Currently, to avoid this, you have to write your template using either no indentation:
Or a weird jumpy indentation:
With the <%~ it could be written as:
And it would output as desired without the "extra" indentation:
Another example:
would produce:
Using with =¶
It would also be handy if the ~ could be used in <%= statements, perhaps as <%~=. This would be excellent for example when templating YAML's:
Which would reindent the statement outcome to produce something like:
This would require these new tags:
<%~begin a code block and begin or end reindentation mode. content produced inside the block will be reindented to the depth of the<character in<%~. If the indentation mode was already active due to a previous<%~, it ends the indentation mode.<%~=like regular<%=but multiline strings will be reindented to the column of the<character