-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from julienbourdeau/feat/turbo-drive
Better support for Turbo Drive (Breaking Change)
- Loading branch information
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |