hud 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hud/version.rb +1 -1
- data/lib/hud.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c81ae686bbd0cd97c469d98c2baaaab165e50859bcd8e40325b31d20baedf95
|
4
|
+
data.tar.gz: 7debdf245e083c85c681c058b73281a74fe3c9d82492606cce23bd6efd21312d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a3d655457bc738523a5eb1fec70ccbbf2f79561a7751db775fe72953761a8c9e47b30045d658db04b723c7376ed25fb0f0448fca17404cce1f312f66777f5cb
|
7
|
+
data.tar.gz: 8e6f24a2ed10b1e9f0675beaa1e6b74885da602c3a0c3aa33f20fb9dec1b650b61c602758573578c84ea640c82fe65920950dac4e6660b00c8016ba710b75e0e
|
data/lib/hud/version.rb
CHANGED
data/lib/hud.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rack/app"
|
2
2
|
require "yaml"
|
3
3
|
require "tilt"
|
4
|
+
require "pry"
|
4
5
|
require "ostruct"
|
5
6
|
require "tilt/erb"
|
6
7
|
require "rack/app/front_end"
|
@@ -15,6 +16,7 @@ module Hud
|
|
15
16
|
|
16
17
|
def self.configure
|
17
18
|
configuration.components_dirs = []
|
19
|
+
configuration.base_path = Pathname.new(Rack::App::Utils.pwd)
|
18
20
|
yield(configuration)
|
19
21
|
end
|
20
22
|
module Middleware
|
@@ -85,6 +87,9 @@ module Hud
|
|
85
87
|
klz = Display.build(name)
|
86
88
|
klz.call(locals: locals).render_template(name: name, locals: @locals, from: from)
|
87
89
|
end
|
90
|
+
alias_method :render, :display
|
91
|
+
alias_method :d, :display
|
92
|
+
alias_method :r, :display
|
88
93
|
end
|
89
94
|
|
90
95
|
def self.build(name)
|
@@ -98,6 +103,7 @@ module Hud
|
|
98
103
|
attr_reader :locals
|
99
104
|
attr_reader :content
|
100
105
|
alias_method :args, :locals
|
106
|
+
|
101
107
|
|
102
108
|
def folders
|
103
109
|
Hud.configuration.components_dirs
|
@@ -107,6 +113,16 @@ module Hud
|
|
107
113
|
ENV["RACK_ENV"] == "development"
|
108
114
|
end
|
109
115
|
|
116
|
+
|
117
|
+
def display(name, locals: {})
|
118
|
+
template = Tilt::ERBTemplate.new("#{Hud.configuration.base_path}/components/#{name.to_s}.html.erb")
|
119
|
+
template.render(self, locals)
|
120
|
+
end
|
121
|
+
|
122
|
+
alias_method :render, :display
|
123
|
+
alias_method :d, :display
|
124
|
+
alias_method :r, :display
|
125
|
+
|
110
126
|
def production?
|
111
127
|
ENV["RACK_ENV"] == "production"
|
112
128
|
end
|
@@ -137,6 +153,7 @@ module Hud
|
|
137
153
|
if File.exist?(path)
|
138
154
|
template = Tilt::ERBTemplate.new(path)
|
139
155
|
|
156
|
+
puts path
|
140
157
|
if from.nil?
|
141
158
|
return template.render(self, locals)
|
142
159
|
else
|