asples_sinatra 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asples_sinatra/helpers.rb +14 -0
- data/lib/asples_sinatra/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9026efc1dcc1b09009accd4c341e1711c00ccfde
|
4
|
+
data.tar.gz: 4b699739d64312a57f664bd40c8a17e39d24d4bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32012a67a37414f1d095fa390450307441a2343f90988688808341ab196cca98f98a0bd880e062b157581781786812b0dfb008d0e7c41594a5589d22af9178b
|
7
|
+
data.tar.gz: e40ed2e41466855620b02b23c56c51e67ede32925afd219e6290a859aac42998c5b64bda621a34101315ca104e1713eaee91208447493406e6558b5b730eb451
|
@@ -1,3 +1,4 @@
|
|
1
|
+
enable :inline_templates
|
1
2
|
module AsplesSinatra
|
2
3
|
module Helpers
|
3
4
|
def input(name, options={})
|
@@ -5,3 +6,16 @@ module AsplesSinatra
|
|
5
6
|
end
|
6
7
|
end
|
7
8
|
end
|
9
|
+
|
10
|
+
|
11
|
+
__END__
|
12
|
+
|
13
|
+
@@ input
|
14
|
+
%div{class: "form-group #{object.errors[field_name].any? && "has-error"}"}
|
15
|
+
-field_type = defined?(as) && as.present? ? as : :text
|
16
|
+
-field_label = defined?(label) && label.present? ? label : field_name.to_s.humanize
|
17
|
+
-field_placeholder = defined?(placeholder) && placeholder.present? ? placeholder : "Enter #{field_name.to_s.humanize.downcase}"
|
18
|
+
%label.control-label{for: field_name}="#{field_label}:"
|
19
|
+
%input{type: field_type, name: field_name, class: "form-control", placeholder: field_placeholder, value: object.send(field_name)}
|
20
|
+
%span.help-block
|
21
|
+
= object.errors[field_name].join('. ') if object.errors.any?
|