Module: Bankrupt

Defined in:
lib/bankrupt.rb,
lib/bankrupt/util.rb,
lib/bankrupt/version.rb

Overview

Copyright 2018 Mario Finelli

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Classes: Util

Constant Summary collapse

ASSET =
Struct.new(:path, :sri).freeze
JAVASCRIPT_CDN =
<<~SLIM
  script crossorigin='anonymous' integrity=sri src=path
SLIM
JAVASCRIPT_LOCAL =
<<~SLIM
  script src=path
SLIM
STYLESHEET_CDN =
<<~SLIM
  link crossorigin='anonymous' href=path integrity=sri rel='stylesheet'
SLIM
STYLESHEET_LOCAL =
<<~SLIM
  link href=path rel='stylesheet'
SLIM
VERSION =
'1.0.0'

Instance Method Summary collapse

Instance Method Details

#javascript(path) ⇒ String

Return a javascript html tag for the asset.

Parameters:

  • path (String)

    relative (from public) path to the js

Returns:

  • (String)

    script html element



44
45
46
# File 'lib/bankrupt.rb', line 44

def javascript(path)
  asset_html(path, JAVASCRIPT_CDN, JAVASCRIPT_LOCAL)
end

#stylesheet(path) ⇒ String

Return a stylesheet html tag for the asset.

Parameters:

  • path (String)

    relative (from public) path to the css

Returns:

  • (String)

    stylesheet html element



52
53
54
# File 'lib/bankrupt.rb', line 52

def stylesheet(path)
  asset_html(path, STYLESHEET_CDN, STYLESHEET_LOCAL)
end