asples_sinatra 0.0.25 → 0.0.26
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 +3 -15
- data/lib/asples_sinatra/templates/input.haml +8 -0
- data/lib/asples_sinatra/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7acec41df3af184e9ff065ce3e6a2e64160f1520
|
4
|
+
data.tar.gz: 666b7a2a0aeb758595f6578717d762856be857a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f67cc53505d37ea574196359fb1ccf086ad22a44e035d57b718c4d82989ab68ba124c0682d192d92d42b85c6bb80016f7127d2e02e8c444d76574f0a4ae511
|
7
|
+
data.tar.gz: 3fa31d7b6c044600e3d675133e76fa38b90fcd69a746f2b46837418bafb6127e132626f6fd29a290b9c5bb03d8a75fb1d021a5bc3743fc53c926e3aa4e9213f2
|
@@ -1,21 +1,9 @@
|
|
1
|
-
enable :inline_templates
|
2
1
|
module AsplesSinatra
|
3
2
|
module Helpers
|
4
3
|
def input(name, options={})
|
5
|
-
|
4
|
+
template_path = File.join(File.dirname(File.expand_path(__FILE__)), '/templates/input.haml')
|
5
|
+
tmpl = Tilt.new(template_path)
|
6
|
+
tmpl.render(self, options.merge!({field_name: name}))
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
9
|
-
|
10
|
-
|
11
|
-
__END__
|
12
|
-
|
13
|
-
@@ input
|
14
|
-
%div{class: "form-group #{object.respond_to?(:errors) && object.errors.has_key?(field_name) && 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.respond_to?(:errors) && object.errors.has_key?(field_name) && object.errors.any?
|
@@ -0,0 +1,8 @@
|
|
1
|
+
%div{class: "form-group #{object.respond_to?(:errors) && object.errors.has_key?(field_name) && object.errors[field_name].any? && "has-error"}"}
|
2
|
+
-field_type = defined?(as) && as.present? ? as : :text
|
3
|
+
-field_label = defined?(label) && label.present? ? label : field_name.to_s.humanize
|
4
|
+
-field_placeholder = defined?(placeholder) && placeholder.present? ? placeholder : "Enter #{field_name.to_s.humanize.downcase}"
|
5
|
+
%label.control-label{for: field_name}="#{field_label}:"
|
6
|
+
%input{type: field_type, name: field_name, class: "form-control", placeholder: field_placeholder, value: object.send(field_name)}
|
7
|
+
%span.help-block
|
8
|
+
= object.errors[field_name].join('. ') if object.respond_to?(:errors) && object.errors.has_key?(field_name) && object.errors.any?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asples_sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Per Evensen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/asples_sinatra.rb
|
106
106
|
- lib/asples_sinatra/helpers.rb
|
107
107
|
- lib/asples_sinatra/sinatra.rb
|
108
|
+
- lib/asples_sinatra/templates/input.haml
|
108
109
|
- lib/asples_sinatra/version.rb
|
109
110
|
homepage: https://github.com/asplespng/asples_sinatra
|
110
111
|
licenses:
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.5.
|
130
|
+
rubygems_version: 2.5.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Helpers for base sinatra app
|