houdini/lib/include_asset.rb

22 lines
626 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-06-12 20:03:43 +00:00
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module IncludeAsset
# These are custom asset include functions for use in views that cache-bust using the current git version
def self.js(path)
%(<script src="#{path}?v=#{asset_version}" type="text/javascript"></script>).html_safe
end
def self.css(path)
%(<link rel='stylesheet' type='text/css' media='all' href="#{path}?v=#{asset_version}">).html_safe
end
private
def self.asset_version
ENV['ASSET_VERSION']
end
end