Skip to content

Commit fb01d24

Browse files
committed
simpler solution
1 parent b6a800e commit fb01d24

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

lib/herb/engine.rb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -286,25 +286,10 @@ def add_expression_block_end(code, escaped: false)
286286

287287
@src.chomp! if @src.end_with?("\n") && code_stripped.start_with?(" ")
288288

289-
has_comment = code.include?("#")
290-
closing = escaped ? "))" : ")"
291-
292-
if has_comment
293-
comment_index = code_stripped.index("#")
294-
code_part = code_stripped[0...comment_index].rstrip
295-
comment_part = code_stripped[comment_index..]
296-
297-
@src << " " << code_part << closing << " " << comment_part << "\n"
298-
else
299-
@src << " " << code_stripped
300-
@src << closing
301-
302-
@src << if trailing_newline
303-
"\n"
304-
else
305-
";"
306-
end
307-
end
289+
@src << " " << code_stripped
290+
@src << "\n" if self.class.comment?(code_stripped)
291+
@src << (escaped ? "))" : ")")
292+
@src << (trailing_newline ? "\n" : ";")
308293

309294
@buffer_on_stack = false
310295
end

0 commit comments

Comments
 (0)