-
Notifications
You must be signed in to change notification settings - Fork 57
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
Multiline comments #126
Conversation
There was a problem hiding this 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.
lib/slime/parser/text_block.ex
Outdated
^ | ||
declaration indent | ||
""" | ||
def render(lines, decl_indent, trailing_whitespace \\ "") do |
There was a problem hiding this comment.
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.
lib/slime/parser/text_block.ex
Outdated
[{first_line_indent, first_line, is_eex_line} | rest] = lines | ||
|
||
text_indent = if first_line == "" do | ||
[{indent, _, _} | _] = rest |
There was a problem hiding this comment.
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)
src/slime_parser.peg.eex
Outdated
% 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); |
There was a problem hiding this comment.
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 / ...
Thanks for your comments, @Rakoth! I've added a test case for 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? |
@little-bobby-tables Since it is already in a separate module, we could simply extract parts of it into private functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
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 atext_block
rule.The change introduces:
/!
)/
)What do you think?