Skip to content

Commit

Permalink
Avoid 'puts' in addons example (#2616)
Browse files Browse the repository at this point in the history
Using `puts` can break the LSP client/server connection.
  • Loading branch information
andyw8 authored Sep 24, 2024
1 parent 00e95a9 commit 8501f5e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions jekyll/add-ons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MyListener

# Define the handler method for the `on_class_node_enter` event
def on_class_node_enter(node)
puts "Hello, #{node.constant_path.slice}!"
$stderr.puts "Hello, #{node.constant_path.slice}!"
end
end

Expand All @@ -118,7 +118,6 @@ dispatcher.dispatch(parse_result.value)

# Prints
# => Hello, Foo!

```

In this example, the listener is registered to the dispatcher to listen for the `:on_class_node_enter` event. When a class node is encountered during the parsing of the code, a greeting message is outputted with the class name.
Expand Down

0 comments on commit 8501f5e

Please sign in to comment.