slim-template/slim

Feature request: Allow white space around pipe text

donv opened this issue ยท 5 comments

donv commented

Hi!

Thank you for this excellent templating engine! It makes my every day better ๐Ÿ˜„ .

It would be nice to allow putting white space before a pipe text like so:

|< Some text with white space before

Similarly white space after text would be nice, although that is possible with apostrophe. I would like it for consistency.

|> Some text with white space after
' Some text with white space after

Using two spaces after the pipe is possible, but it is a maintenance nightmare since it is easily removed by source code formatters or unaware developers or even just by accident since double space is not very visible.

|  Some text with white space before
| Some text without white space before

And of course white space before and after would also be useful:

|<> Some text with white space before and after.

A very common case for us is a conditional text which is appended to another text, and we want white space before the text only when the text is present:

| Start
- if some_condition
  |< Some text with white space before

Would this be possible, or does it break some other syntax?

donv commented

I would still love to have this feature. Would you like me to submit a pull request?

minad commented

@donv If there is interest, I would appreciate a PR which implements this feature and updates the documentation. As you argue, this would improve consistency.

I will have a look.

We will submit a PR for this.

I am starting on this now. I will ask for help to find my way around the code if needed.