lib/phlex/rails/layout.rb in phlex-rails-1.1.2 vs lib/phlex/rails/layout.rb in phlex-rails-1.2.0
- old
+ new
@@ -4,37 +4,23 @@
module Layout
include Helpers::CSPMetaTag
include Helpers::CSRFMetaTags
include Helpers::FaviconLinkTag
include Helpers::PreloadLinkTag
- include Helpers::StyleSheetLinkTag
+ include Helpers::StylesheetLinkTag
include Helpers::ActionCableMetaTag
include Helpers::AutoDiscoveryLinkTag
- include Helpers::JavaScriptIncludeTag
- include Helpers::JavaScriptImportMapTags
- include Helpers::JavaScriptImportModuleTag
+ include Helpers::JavascriptIncludeTag
+ include Helpers::JavascriptImportmapTags
+ include Helpers::JavascriptImportModuleTag
+ include Helpers::TurboRefreshMethodTag
+ include Helpers::TurboRefreshScrollTag
# @api private
module Interface
- def render(view, _locals, &block)
- component = new
-
- component.call(view_context: view) do |yielded|
- case yielded
- when Symbol
- output = view.view_flow.get(yielded)
- else
- output = yield
- end
-
- case output
- when ActiveSupport::SafeBuffer
- component.unsafe_raw output
- end
-
- nil
- end
+ def render(view_context, _locals, &block)
+ new.render(view_context, &block)
end
def identifier
name
end
@@ -55,8 +41,33 @@
raise Phlex::ArgumentError,
"👋 #{name} should only be included into Phlex::HTML classes."
end
klass.extend(Interface)
+ end
+
+ def render(view_context, *args, **kwargs, &block)
+ if @_context
+ super
+ else
+ call(view_context: view_context) do |yielded|
+ case yielded
+ when Symbol
+ output = view_context.view_flow.get(yielded)
+ else
+ output = view_context.capture(&block)
+ end
+
+ unsafe_raw output
+ end
+ end
+ end
+
+ def identifier
+ self.class.identifier
+ end
+
+ def virtual_path
+ self.class.virtual_path
end
end
end