module Ui::AssetsHelper
Public Instance Methods
css_load(ext: '.css', **options)
click to toggle source
Assets path: app/assets/stylesheets/controllers
# File lib/viter/assets_helper.rb, line 22 def css_load(ext: '.css', **options) path, _ = assets_load_path(ext: ext, suffix: options.delete(:suffix)) options[:host] = Viter.instance.config.host if Rails.env.development? if path stylesheet_link_tag("/#{path}", **options) end end
js_load(ext: '.js', **options)
click to toggle source
# File lib/viter/assets_helper.rb, line 12 def js_load(ext: '.js', **options) path, _ = assets_load_path(ext: ext, suffix: options.delete(:suffix)) options[:host] = Viter.instance.config.host if Rails.env.development? if path javascript_include_tag("/#{path}", type: 'module', **options) end end
pack_path(ext:, **options)
click to toggle source
Assets path: app/assets/javascripts/controllers
# File lib/viter/assets_helper.rb, line 6 def pack_path(ext:, **options) path, ext = assets_load_path(ext: ext, suffix: options.delete(:suffix)) asset_vite_path(path + ext) end
Private Instance Methods
assets_load_path(ext: '.js', suffix: nil)
click to toggle source
# File lib/viter/assets_helper.rb, line 32 def assets_load_path(ext: '.js', suffix: nil) filename = "#{controller_path}/#{@_rendered_template}" filename = [filename, '-', suffix].join if suffix pathname = Pathname.new(@_rendered_template_path) js_name = pathname.without_extname.sub_ext ext r = Viter.manifest.lookup_by_path(js_name) if r && Rails.env.development? [js_name.to_s, ext] elsif r [r['file']] else [] end end