Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline comments #126

Merged
merged 6 commits into from
May 23, 2017
Merged

Conversation

little-bobby-tables
Copy link
Contributor

I've noticed that Slim handles HTML comments (/!) just like verbatim text nodes (| and ') — complete with interpolation — so I decided to move the common semantics into a text_block rule.

The change introduces:

  • multiline HTML comments (/!)
  • text interpolation in HTML comments
  • mutlilne code comments (/)

What do you think?

Copy link
Member

@Rakoth Rakoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @little-bobby-tables, great job refactoring this nasty verbatim_text transform! I left some comments below, please take a look.

^
declaration indent
"""
def render(lines, decl_indent, trailing_whitespace \\ "") do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be use declaration_indent as variable name? An abbreviation is a bit confusing.

[{first_line_indent, first_line, is_eex_line} | rest] = lines

text_indent = if first_line == "" do
[{indent, _, _} | _] = rest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about single ' used for spacing, example similar to one in my work project:

p
  '
  span text
  ' .

I understand, span< could be used here, but it is a valid slim and should be supported (probably should add a test case for it)

% NOTE: We have to track leading spaces for verbatim_text, so it handled separately
tag <- verbatim_text / space? tag_item / blank:(space? &eol);
% NOTE: Leading whitespace is handled separately for text items
tag <- text_item / space? tag_item / blank:(space? &eol);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to keep verbatim_text separated from comment, so here it would be comment / verbatim_text / ...

@little-bobby-tables
Copy link
Contributor Author

Thanks for your comments, @Rakoth! I've added a test case for ' without content and split text_item into verbatim_text and comment.

However, I've noticed that credo now reports the TextBlock.render function as having excessively high ABC complexity — do you have any ideas on how to refactor it?

@Rakoth
Copy link
Member

Rakoth commented May 21, 2017

@little-bobby-tables Since it is already in a separate module, we could simply extract parts of it into private functions.

Copy link
Member

@Rakoth Rakoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Rakoth Rakoth merged commit 0209bdd into slime-lang:master May 23, 2017
@little-bobby-tables little-bobby-tables deleted the text-blocks branch May 28, 2017 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants