backbone_form_helper 0.0.1 → 0.0.1.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,19 @@
1
1
  # BackboneFormHelper
2
2
 
3
- TODO: Write a gem description
3
+ This Rails gem provide javascript form helper based on Rails principle like 'f.text_field
4
+ :name'. For each helper exist template so you can create your own
5
+ template for each of them (eg. /templates/text_field). Now are templates
6
+ created in Twitter bootstrap style.
7
+
8
+ **This is still alpha.**
4
9
 
5
10
  ## Installation
6
11
 
12
+ External dependencies:
13
+
14
+ * underscore.js
15
+ * coffee-rails for assets (now js are written in .coffee)
16
+
7
17
  Add this line to your application's Gemfile:
8
18
 
9
19
  gem 'backbone_form_helper'
@@ -16,9 +26,53 @@ Or install it yourself as:
16
26
 
17
27
  $ gem install backbone_form_helper
18
28
 
29
+
30
+ Add this line into your application.js:
31
+
32
+ ```js
33
+ //= require form_helper/form_helper
34
+ ```
35
+
36
+ Add this line into your application.scss:
37
+
38
+ ```scss
39
+ @import 'form_helper/form_helper';
40
+ ```
41
+
42
+ ## Helper list
43
+ For now:
44
+
45
+ * label
46
+ * text_field
47
+ * text_area
48
+ * select
49
+ * select_tag
50
+ * check_box
51
+ * date_field
52
+
19
53
  ## Usage
20
54
 
21
- TODO: Write usage instructions here
55
+ <% form = new FormHelper @task %>
56
+ <%- form.check_box 'is_done', title: 'Is done' %>
57
+ <%- form.date_field 'date', class: 'text_field', placeholder: 'datum' %>
58
+ <%- form.text_area 'description', placeholder: 'ukol' %>
59
+ <%- form.select 'group_id', values: _.map(@groups, (g) -> [g.get('_id'), g.get('name')]) %>
60
+ <%- form.select 'user_id', values: _.map(@users, (g) -> [g.get('_id'), g.get('name')]) %>
61
+
62
+
63
+ Value and errors are taken from model automaticly how Rails do it and shown in template (eg. text_field template):
64
+
65
+ <input type="text" id="<%= @field_id %>" <%- @unfold_options %> name="<%= @field_name %>" value="<%= @value %>" />
66
+ <span class="help-inline">
67
+ <%= @errors if @errors %>
68
+ </span>
69
+
70
+ so after render when model has error on name (model.errors['name'] or model.get('errors')['name']) it looks like:
71
+
72
+ <input type="text" id="task_name" placeholder="ukol" class="error" name="task[name]" value="">
73
+ <span class="help-inline">
74
+ can't be blank
75
+ </span>
22
76
 
23
77
  ## Contributing
24
78
 
@@ -4,9 +4,10 @@ require File.expand_path('../lib/backbone_form_helper/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Zdenal"]
6
6
  gem.email = ["nevralaz@gmail.com"]
7
- gem.description = %q{Form helper for backbone on Rails priciple -> f.text_field :name}
7
+ gem.description = %q{Form helper for backbone based on Rails priciple -> f.text_field :name}
8
8
  gem.summary = %q{Backbone form helper}
9
- gem.homepage = ""
9
+ gem.homepage = "http://github.com/zdenal/backbone_form_helper.git"
10
+ gem.rubyforge_project = "backbone_form_helper"
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -0,0 +1,6 @@
1
+ module BackboneFormHelper
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module BackboneFormHelper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.1.1.alpha"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require "backbone_form_helper/version"
2
+ require "backbone_form_helper/engine"
2
3
 
3
4
  module BackboneFormHelper
4
- # Your code goes here...
5
5
  end