You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
780 B

module SiteHelper
def frontend_javascript_importmap_tags
only_use = %w"application"
importmap_json = JSON.parse(Rails.application.importmap.to_json(resolver: self))['imports'].select{ |k,v| only_use.include?(k)}
safe_join [
javascript_inline_importmap_tag(JSON.pretty_generate({ "imports" => importmap_json})),
javascript_module_preload_tag(*importmap_json.map{|v| v[1]}),
javascript_import_module_tag('application')
], "\n"
end
def node_title(node)
parts = [node.page_title.blank? ? node.title : node.page_title ]
parts << t(:client_name)
parts.uniq.join(' - ')
rescue
t(:client_name)
end
def random_value(from, to)
range = rand(2) == 0 ? (-to..-from) : (from..to)
rand(range)
end
end