instance method
to_json
Ruby on Rails 1.2.3
Since v1.0.3 Last seen in v2.2.3Signature
to_json(resolver:, cache_key: :json)
Returns a JSON hash (as a string) of all the resolved module paths of the pinned packages in the import map format. The resolver must respond to path_to_asset, such as ActionController::Base.helpers or ApplicationController.helpers. You’ll want to use the resolver that has been configured for the asset_host you want these resolved paths to use. In case you need to resolve for different asset hosts, you can pass in a custom cache_key to vary the cache used by this method for the different cases.
Parameters
-
resolverkeyreq -
cache_keykey = :json
Source
# File lib/importmap/map.rb, line 54
def to_json(resolver:, cache_key: :json)
cache_as(cache_key) do
JSON.pretty_generate({ "imports" => resolve_asset_paths(expanded_packages_and_directories, resolver: resolver) })
end
end
Defined in lib/importmap/map.rb line 54
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Importmap::Map