Module: Theme::Assets
- Defined in:
- lib/theme/assets.rb,
lib/theme/assets/render.rb,
lib/theme/assets/middleware.rb
Defined Under Namespace
Modules: Render
Classes: Middleware
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.compile ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/theme/assets.rb', line 49
def compile
Theme.config.assets.to_h.each do |type, assets|
content = ''
if assets.length > 0
type_path = "#{Theme.config.asset_path}/#{Theme.config[:"asset_#{type}_folder"]}"
assets.each do |file|
path = "#{type_path}/#{file}"
content += Theme.load_file path
end
tmp_path = "#{type_path}/tmp.dominate-compiled.#{type}"
File.write tmp_path, content
system "minify #{tmp_path} > #{type_path}/dominate-compiled.#{type}"
File.delete tmp_path
end
end
end
|
.css_assets(options = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/theme/assets.rb', line 14
def css_assets options = {}
options = {
'data-turbolinks-track' => 'true',
rel: 'stylesheet',
type: 'text/css',
media: 'all'
}.merge options
url = Theme.config.asset_url
if Theme.config.assets_compiled
options[:href] = "#{url}/css/all-#{sha}.css"
else
options[:href] = "#{url}/css/all.css"
end
mab { link options }
end
|
.js_assets(options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/theme/assets.rb', line 33
def js_assets options = {}
options = {
'data-turbolinks-track' => 'true',
}.merge options
url = Theme.config.asset_url
if Theme.config.assets_compiled
options[:src] = "#{url}/js/all-#{sha}.js"
else
options[:src] = "#{url}/js/all.js"
end
mab { script options }
end
|
.setup(app) ⇒ Object
9
10
11
12
|
# File 'lib/theme/assets.rb', line 9
def setup app
app.plugin Render
app.use Middleware
end
|
Instance Method Details
#css_assets(options = {}) ⇒ Object
68
69
70
|
# File 'lib/theme/assets.rb', line 68
def css_assets options = {}
Theme::Assets.css_assets options
end
|
#js_assets(options = {}) ⇒ Object
72
73
74
|
# File 'lib/theme/assets.rb', line 72
def js_assets options = {}
Theme::Assets.js_assets options
end
|