Skip to content

Commit

Permalink
Merge pull request #26 from julienbourdeau/feat/turbo-drive
Browse files Browse the repository at this point in the history
Better support for Turbo Drive (Breaking Change)
  • Loading branch information
julienbourdeau committed Mar 30, 2024
2 parents 7cb781b + d78bcb9 commit 6f7fc11
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.3.0 - 2024-03-30

* Add support for Turbo Drive - See [#25](https://github.com/julienbourdeau/debugbar/pull/25) and [#26](https://github.com/julienbourdeau/debugbar/pull/26)
*

## v0.2.0 - 2024-02-28

* Introduce polling in case someone cannot use ActiveCable - See [8b262be7](https://github.com/julienbourdeau/debugbar/commit/8b262be7b644c7b587a6c3348bb02076053a344f)
Expand Down
27 changes: 23 additions & 4 deletions app/helpers/debugbar/tag_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
module Debugbar::TagHelpers
def debugbar_javascript(opt = {})
def debugbar_head
raw <<-HTML
<script defer src="#{Debugbar.config.prefix}/assets/script"></script>
HTML
end

def debugbar_body(opt = {})
opt = ActiveSupport::HashWithIndifferentAccess.new(opt)

# See https://github.com/julienbourdeau/debugbar/issues/8
if !defined?(ActionCable) && opt[:mode].nil?
opt[:mode] = 'poll'
end

raw(<<~HTML)
html = <<-HTML
<div id="__debugbar" data-turbo-permanent></div>
<script type="text/javascript">
HTML

html += <<-HTML
<script type="text/javascript" data-turbo-permanent>
window._debugbarConfigOptions = #{opt.to_json}
</script>
<script defer src="#{Debugbar.config.prefix}/assets/script"></script>
HTML

raw html
end

def debugbar_javascript(opt = {})
errors = []
errors << "debugbar_javascript was removed in 0.3.0."
errors << "Please use `debugbar_head` inside <head> and `debugbar_body(opt_hash)` at the end of <body> instead."
errors << "It was split to support Turbo Drive."
errors << "See https://debugbar.dev/changelog/ for more information."
raise errors.join("\n")
end
end

0 comments on commit 6f7fc11

Please sign in to comment.