Skip to content

Commit 99ffb3d

Browse files
authored
Dev Tools: Set <meta name="herb-default-editor"> for Herb (#51)
See marcoroth/herb#715 Resolves #3
1 parent 7809b42 commit 99ffb3d

File tree

1 file changed

+17
-1
lines changed
  • lib/reactionview/template/handlers

1 file changed

+17
-1
lines changed

lib/reactionview/template/handlers/herb.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,29 @@ def local_template?(template)
4343
template.identifier.start_with?("#{Rails.root}/app/views")
4444
end
4545

46+
def active_support_editor
47+
return unless defined?(ActiveSupport::Editor)
48+
return if ActiveSupport::Editor.current.blank?
49+
50+
ActiveSupport::Editor.current.instance_variable_get(:@url_pattern).split("://").first
51+
end
52+
53+
def editor_meta_tag
54+
editor_name = active_support_editor || ENV["RAILS_EDITOR"] || ENV.fetch("EDITOR", nil)
55+
56+
return if editor_name.blank?
57+
58+
%(<meta name="herb-default-editor" content="#{editor_name}">)
59+
end
60+
4661
def reactionview_dev_tools_markup(template)
4762
return nil unless layout_template?(template) && ::ReActionView.config.debug_mode_enabled?
4863
return nil unless local_template?(template)
4964

5065
<<~HTML
5166
<meta name="herb-debug-mode" content="true">
52-
<meta name="herb-rails-root" content="#{Rails.root}">
67+
<meta name="herb-project-path" content="#{Rails.root}">
68+
#{editor_meta_tag}
5369
5470
#{ActionController::Base.new.view_context.javascript_include_tag "reactionview-dev-tools.umd.js", defer: true}
5571
HTML

0 commit comments

Comments
 (0)