Class: CKEditor5::Rails::Assets::AssetsBundleHtmlSerializer
- Inherits:
-
Object
- Object
- CKEditor5::Rails::Assets::AssetsBundleHtmlSerializer
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb
Instance Attribute Summary collapse
-
#bundle ⇒ Object
readonly
Returns the value of attribute bundle.
-
#importmap ⇒ Object
readonly
Returns the value of attribute importmap.
-
#lazy ⇒ Object
readonly
Returns the value of attribute lazy.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bundle, importmap: true, lazy: false) ⇒ AssetsBundleHtmlSerializer
constructor
A new instance of AssetsBundleHtmlSerializer.
- #to_html(nonce: nil) ⇒ Object
Constructor Details
#initialize(bundle, importmap: true, lazy: false) ⇒ AssetsBundleHtmlSerializer
Returns a new instance of AssetsBundleHtmlSerializer.
14 15 16 17 18 19 20 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 14 def initialize(bundle, importmap: true, lazy: false) raise TypeError, 'bundle must be an instance of AssetsBundle' unless bundle.is_a?(AssetsBundle) @importmap = importmap @bundle = bundle @lazy = lazy end |
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
12 13 14 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 12 def bundle @bundle end |
#importmap ⇒ Object (readonly)
Returns the value of attribute importmap.
12 13 14 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 12 def importmap @importmap end |
#lazy ⇒ Object (readonly)
Returns the value of attribute lazy.
12 13 14 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 12 def lazy @lazy end |
Class Method Details
.url_resource_preload_type(url) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 44 def self.url_resource_preload_type(url) case File.extname(url) when '.js' then 'script' when '.css' then 'style' else 'fetch' end end |
Instance Method Details
#to_html(nonce: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb', line 22 def to_html(nonce: nil) = [ WebComponentBundle.instance.to_html(nonce: nonce) ] unless lazy .prepend( (nonce: nonce), (nonce: nonce), (nonce: nonce) ) end if importmap .prepend( AssetsImportMap.new(bundle).to_html(nonce: nonce) ) end safe_join() end |