tennpipes-helper 3.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +239 -0
- data/Rakefile +1 -0
- data/lib/tennpipes-helper.rb +62 -0
- data/lib/tennpipes-helper/asset_tag_helpers.rb +394 -0
- data/lib/tennpipes-helper/form_builder/abstract_form_builder.rb +279 -0
- data/lib/tennpipes-helper/form_builder/standard_form_builder.rb +40 -0
- data/lib/tennpipes-helper/form_helpers.rb +639 -0
- data/lib/tennpipes-helper/form_helpers/errors.rb +138 -0
- data/lib/tennpipes-helper/form_helpers/options.rb +98 -0
- data/lib/tennpipes-helper/form_helpers/security.rb +70 -0
- data/lib/tennpipes-helper/format_helpers.rb +372 -0
- data/lib/tennpipes-helper/locale/cs.yml +103 -0
- data/lib/tennpipes-helper/locale/da.yml +91 -0
- data/lib/tennpipes-helper/locale/de.yml +81 -0
- data/lib/tennpipes-helper/locale/en.yml +103 -0
- data/lib/tennpipes-helper/locale/es.yml +103 -0
- data/lib/tennpipes-helper/locale/fr.yml +79 -0
- data/lib/tennpipes-helper/locale/hu.yml +103 -0
- data/lib/tennpipes-helper/locale/it.yml +89 -0
- data/lib/tennpipes-helper/locale/ja.yml +103 -0
- data/lib/tennpipes-helper/locale/lv.yml +103 -0
- data/lib/tennpipes-helper/locale/nl.yml +82 -0
- data/lib/tennpipes-helper/locale/no.yml +91 -0
- data/lib/tennpipes-helper/locale/pl.yml +95 -0
- data/lib/tennpipes-helper/locale/pt_br.yml +103 -0
- data/lib/tennpipes-helper/locale/ro.yml +103 -0
- data/lib/tennpipes-helper/locale/ru.yml +103 -0
- data/lib/tennpipes-helper/locale/sv.yml +103 -0
- data/lib/tennpipes-helper/locale/tr.yml +103 -0
- data/lib/tennpipes-helper/locale/uk.yml +103 -0
- data/lib/tennpipes-helper/locale/zh_cn.yml +103 -0
- data/lib/tennpipes-helper/locale/zh_tw.yml +103 -0
- data/lib/tennpipes-helper/number_helpers.rb +283 -0
- data/lib/tennpipes-helper/output_helpers.rb +226 -0
- data/lib/tennpipes-helper/output_helpers/abstract_handler.rb +61 -0
- data/lib/tennpipes-helper/output_helpers/erb_handler.rb +27 -0
- data/lib/tennpipes-helper/output_helpers/haml_handler.rb +25 -0
- data/lib/tennpipes-helper/output_helpers/slim_handler.rb +18 -0
- data/lib/tennpipes-helper/render_helpers.rb +63 -0
- data/lib/tennpipes-helper/tag_helpers.rb +294 -0
- data/lib/tennpipes-helper/translation_helpers.rb +36 -0
- data/lib/tennpipes/rendering.rb +369 -0
- data/lib/tennpipes/rendering/erb_template.rb +40 -0
- data/lib/tennpipes/rendering/erubis_template.rb +66 -0
- data/lib/tennpipes/rendering/haml_template.rb +26 -0
- data/lib/tennpipes/rendering/slim_template.rb +20 -0
- data/test/fixtures/apps/render.rb +25 -0
- data/test/fixtures/apps/views/article/comment/show.slim +1 -0
- data/test/fixtures/apps/views/blog/post.erb +1 -0
- data/test/fixtures/apps/views/layouts/specific.erb +1 -0
- data/test/fixtures/apps/views/test/post.erb +1 -0
- data/test/fixtures/layouts/layout.erb +1 -0
- data/test/fixtures/markup_app/app.rb +87 -0
- data/test/fixtures/markup_app/views/button_to.erb +8 -0
- data/test/fixtures/markup_app/views/button_to.haml +5 -0
- data/test/fixtures/markup_app/views/button_to.slim +6 -0
- data/test/fixtures/markup_app/views/capture_concat.erb +14 -0
- data/test/fixtures/markup_app/views/capture_concat.haml +12 -0
- data/test/fixtures/markup_app/views/capture_concat.slim +12 -0
- data/test/fixtures/markup_app/views/content_for.erb +23 -0
- data/test/fixtures/markup_app/views/content_for.haml +19 -0
- data/test/fixtures/markup_app/views/content_for.slim +19 -0
- data/test/fixtures/markup_app/views/content_tag.erb +13 -0
- data/test/fixtures/markup_app/views/content_tag.haml +11 -0
- data/test/fixtures/markup_app/views/content_tag.slim +11 -0
- data/test/fixtures/markup_app/views/current_engine.erb +5 -0
- data/test/fixtures/markup_app/views/current_engine.haml +5 -0
- data/test/fixtures/markup_app/views/current_engine.slim +5 -0
- data/test/fixtures/markup_app/views/fields_for.erb +20 -0
- data/test/fixtures/markup_app/views/fields_for.haml +15 -0
- data/test/fixtures/markup_app/views/fields_for.slim +15 -0
- data/test/fixtures/markup_app/views/form_for.erb +72 -0
- data/test/fixtures/markup_app/views/form_for.haml +59 -0
- data/test/fixtures/markup_app/views/form_for.slim +59 -0
- data/test/fixtures/markup_app/views/form_tag.erb +95 -0
- data/test/fixtures/markup_app/views/form_tag.haml +78 -0
- data/test/fixtures/markup_app/views/form_tag.slim +79 -0
- data/test/fixtures/markup_app/views/link_to.erb +5 -0
- data/test/fixtures/markup_app/views/link_to.haml +4 -0
- data/test/fixtures/markup_app/views/link_to.slim +4 -0
- data/test/fixtures/markup_app/views/mail_to.erb +3 -0
- data/test/fixtures/markup_app/views/mail_to.haml +3 -0
- data/test/fixtures/markup_app/views/mail_to.slim +3 -0
- data/test/fixtures/markup_app/views/meta_tag.erb +3 -0
- data/test/fixtures/markup_app/views/meta_tag.haml +3 -0
- data/test/fixtures/markup_app/views/meta_tag.slim +3 -0
- data/test/fixtures/markup_app/views/partials/_erb.erb +1 -0
- data/test/fixtures/markup_app/views/partials/_haml.haml +1 -0
- data/test/fixtures/markup_app/views/partials/_slim.slim +1 -0
- data/test/fixtures/markup_app/views/simple_partial.erb +1 -0
- data/test/fixtures/markup_app/views/simple_partial.haml +1 -0
- data/test/fixtures/markup_app/views/simple_partial.slim +1 -0
- data/test/fixtures/render_app/app.rb +110 -0
- data/test/fixtures/render_app/views/_deep.erb +3 -0
- data/test/fixtures/render_app/views/_deep.haml +2 -0
- data/test/fixtures/render_app/views/_deep.slim +2 -0
- data/test/fixtures/render_app/views/_partial_block_erb.erb +10 -0
- data/test/fixtures/render_app/views/_partial_block_haml.haml +7 -0
- data/test/fixtures/render_app/views/_partial_block_slim.slim +7 -0
- data/test/fixtures/render_app/views/_unsafe.html.builder +2 -0
- data/test/fixtures/render_app/views/_unsafe_object.html.builder +2 -0
- data/test/fixtures/render_app/views/current_engine.haml +5 -0
- data/test/fixtures/render_app/views/current_engines/_erb.erb +1 -0
- data/test/fixtures/render_app/views/current_engines/_haml.haml +1 -0
- data/test/fixtures/render_app/views/current_engines/_slim.slim +1 -0
- data/test/fixtures/render_app/views/dive_inner_erb.erb +3 -0
- data/test/fixtures/render_app/views/dive_inner_haml.haml +2 -0
- data/test/fixtures/render_app/views/dive_inner_slim.slim +2 -0
- data/test/fixtures/render_app/views/dive_outer_erb.erb +3 -0
- data/test/fixtures/render_app/views/dive_outer_haml.haml +2 -0
- data/test/fixtures/render_app/views/dive_outer_slim.slim +2 -0
- data/test/fixtures/render_app/views/double_capture_erb.erb +3 -0
- data/test/fixtures/render_app/views/double_capture_haml.haml +2 -0
- data/test/fixtures/render_app/views/double_capture_slim.slim +2 -0
- data/test/fixtures/render_app/views/erb/test.erb +1 -0
- data/test/fixtures/render_app/views/explicit_engine.haml +5 -0
- data/test/fixtures/render_app/views/haml/test.haml +1 -0
- data/test/fixtures/render_app/views/render_block_erb.erb +5 -0
- data/test/fixtures/render_app/views/render_block_haml.haml +4 -0
- data/test/fixtures/render_app/views/render_block_slim.slim +4 -0
- data/test/fixtures/render_app/views/ruby_block_capture_erb.erb +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_haml.haml +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_slim.slim +1 -0
- data/test/fixtures/render_app/views/template/_user.haml +7 -0
- data/test/fixtures/render_app/views/template/haml_template.haml +1 -0
- data/test/fixtures/render_app/views/template/some_template.haml +2 -0
- data/test/fixtures/render_app/views/wrong_capture_erb.erb +3 -0
- data/test/fixtures/render_app/views/wrong_capture_haml.haml +2 -0
- data/test/fixtures/render_app/views/wrong_capture_slim.slim +2 -0
- data/test/helper.rb +88 -0
- data/test/test_asset_tag_helpers.rb +401 -0
- data/test/test_form_builder.rb +1216 -0
- data/test/test_form_helpers.rb +1056 -0
- data/test/test_format_helpers.rb +251 -0
- data/test/test_helpers.rb +10 -0
- data/test/test_locale.rb +20 -0
- data/test/test_number_helpers.rb +142 -0
- data/test/test_output_helpers.rb +157 -0
- data/test/test_render_helpers.rb +225 -0
- data/test/test_rendering.rb +706 -0
- data/test/test_rendering_extensions.rb +14 -0
- data/test/test_tag_helpers.rb +131 -0
- metadata +299 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module Haml
|
2
|
+
module Helpers
|
3
|
+
include XssMods
|
4
|
+
include ActionViewExtensions
|
5
|
+
end
|
6
|
+
|
7
|
+
module Util
|
8
|
+
def self.rails_xss_safe?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Tennpipes
|
15
|
+
module Rendering
|
16
|
+
class HamlTemplate < Tilt::HamlTemplate
|
17
|
+
include SafeTemplate
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Tilt.prefer(Tennpipes::Rendering::HamlTemplate, :haml)
|
23
|
+
|
24
|
+
Tennpipes::Rendering.engine_configurations[:haml] = {
|
25
|
+
:escape_html => true,
|
26
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tennpipes
|
2
|
+
module Rendering
|
3
|
+
class SlimTemplate < Slim::Template
|
4
|
+
include SafeTemplate
|
5
|
+
|
6
|
+
def precompiled_preamble(locals)
|
7
|
+
"__in_slim_template = true\n" << super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Tilt.prefer(Tennpipes::Rendering::SlimTemplate, :slim)
|
14
|
+
|
15
|
+
Tennpipes::Rendering.engine_configurations[:slim] = {
|
16
|
+
:generator => Temple::Generators::RailsOutputBuffer,
|
17
|
+
:buffer => "@_out_buf",
|
18
|
+
:use_html_safe => true,
|
19
|
+
:disable_capture => true,
|
20
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
TENNPIPES_ROOT = File.dirname(__FILE__) unless defined? TENNPIPES_ROOT
|
2
|
+
|
3
|
+
class RenderDemo2 < Tennpipes::Application
|
4
|
+
register Tennpipes::Rendering
|
5
|
+
|
6
|
+
set :reload, true
|
7
|
+
end
|
8
|
+
|
9
|
+
RenderDemo2.controllers :blog do
|
10
|
+
get '/' do
|
11
|
+
render 'post'
|
12
|
+
end
|
13
|
+
|
14
|
+
get '/override' do
|
15
|
+
render 'post', :layout => RenderDemo2.layout_path('specific')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
RenderDemo2.controllers :article, :comment do
|
20
|
+
get '/' do
|
21
|
+
render 'show'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Tennpipes.load!
|
@@ -0,0 +1 @@
|
|
1
|
+
| okay comment
|
@@ -0,0 +1 @@
|
|
1
|
+
okay
|
@@ -0,0 +1 @@
|
|
1
|
+
otay
|
@@ -0,0 +1 @@
|
|
1
|
+
test
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %> absolute layout
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'tennpipes-base'
|
2
|
+
|
3
|
+
class MarkupDemo < Sinatra::Base
|
4
|
+
register Tennpipes::Helpers
|
5
|
+
|
6
|
+
configure do
|
7
|
+
set :logging, false
|
8
|
+
set :tennpipes_logging, false
|
9
|
+
set :environment, :test
|
10
|
+
set :root, File.dirname(__FILE__)
|
11
|
+
set :sessions, true
|
12
|
+
set :protect_from_csrf, true
|
13
|
+
end
|
14
|
+
|
15
|
+
get '/:engine/:file' do
|
16
|
+
show(params[:engine], params[:file].to_sym)
|
17
|
+
end
|
18
|
+
|
19
|
+
helpers do
|
20
|
+
# show :erb, :index
|
21
|
+
# show :haml, :index
|
22
|
+
def show(kind, template)
|
23
|
+
send kind.to_sym, template.to_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
def captured_content(&block)
|
27
|
+
content_html = capture_html(&block)
|
28
|
+
"<p>#{content_html}</p>".html_safe
|
29
|
+
end
|
30
|
+
|
31
|
+
def concat_in_p(content_html)
|
32
|
+
concat_safe_content "<p>#{content_html}</p>"
|
33
|
+
end
|
34
|
+
|
35
|
+
def concat_if_block_is_template(name, &block)
|
36
|
+
concat_safe_content "<p class='is_template'>The #{name} block passed in is a template</p>" if block_is_template?(block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def concat_ruby_not_template_block
|
40
|
+
concat_if_block_is_template('ruby') do
|
41
|
+
content_tag(:span, "This not a template block")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def content_tag_with_block
|
46
|
+
one = content_tag(:p) do
|
47
|
+
"one"
|
48
|
+
end
|
49
|
+
two = content_tag(:p) do
|
50
|
+
"two"
|
51
|
+
end
|
52
|
+
one << two
|
53
|
+
rescue
|
54
|
+
"<p>failed</p>".html_safe
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class MarkupUser
|
60
|
+
def errors; { :fake => "must be valid", :second => "must be present", :third => "must be a number", :email => "must be an email"}; end
|
61
|
+
def session_id; 45; end
|
62
|
+
def gender; 'male'; end
|
63
|
+
def remember_me; '1'; end
|
64
|
+
def permission; Permission.new; end
|
65
|
+
def telephone; Telephone.new; end
|
66
|
+
def addresses; [Address.new('Greenfield', true), Address.new('Willowrun', false)]; end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Telephone
|
70
|
+
def number; "62634576545"; end
|
71
|
+
end
|
72
|
+
|
73
|
+
class Address
|
74
|
+
attr_accessor :name
|
75
|
+
def initialize(name, existing); @name, @existing = name, existing; end
|
76
|
+
def new_record?; !@existing; end
|
77
|
+
def id; @existing ? 25 : nil; end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Permission
|
81
|
+
def can_edit; true; end
|
82
|
+
def can_delete; false; end
|
83
|
+
end
|
84
|
+
|
85
|
+
module Outer
|
86
|
+
class UserAccount; end
|
87
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% button_to 'Foo button', '/foo', :class => 'foo-form' do %>
|
2
|
+
<% field_set_tag do %>
|
3
|
+
<%= hidden_field_tag :session_id, :value => "__secret__" %>
|
4
|
+
<%= label_tag :username %>
|
5
|
+
<% end %>
|
6
|
+
<% end %>
|
7
|
+
<%= content_tag(:p, 'button_to test', :id => 'test-point') %>
|
8
|
+
<%= button_to 'Bar button', '/bar' %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% @content = captured_content do %>
|
2
|
+
<span>Captured Line 1</span>
|
3
|
+
<span>Captured Line 2</span>
|
4
|
+
<% end %>
|
5
|
+
<%= @content %>
|
6
|
+
|
7
|
+
<% concat_in_p('Concat Line 3') %>
|
8
|
+
|
9
|
+
<% concat_if_block_is_template('erb') do %>
|
10
|
+
<span>This is erb</span>
|
11
|
+
<span>This is erb</span>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% concat_ruby_not_template_block %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% content_for :demo do %>
|
2
|
+
<h1>This is content yielded from a content_for</h1>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<div class='demo'><%= yield_content :demo %></div>
|
6
|
+
|
7
|
+
<% content_for :demo2 do |fname, lname| %>
|
8
|
+
<h1>This is content yielded with name <%= fname + " " + lname %></h1>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<div class='demo2'><%= yield_content :demo2, "Johnny", "Smith" %></div>
|
12
|
+
|
13
|
+
<div class="demo_has_content"><%= content_for?(:demo).to_s %>
|
14
|
+
<div class="fake_has_content"><%= content_for?(:fake).to_s %>
|
15
|
+
|
16
|
+
<% content_for :demo3 do %>
|
17
|
+
<p class="duplication">One</p>
|
18
|
+
<% end %>
|
19
|
+
<% content_for :demo3, :flush => true do %>
|
20
|
+
<p class="duplication">Two</p>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<div class="demo3"><%= yield_content :demo3 %></div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- content_for :demo do
|
2
|
+
%h1 This is content yielded from a content_for
|
3
|
+
|
4
|
+
.demo= yield_content :demo
|
5
|
+
|
6
|
+
- content_for :demo2 do |fname, lname|
|
7
|
+
%h1 This is content yielded with name #{fname + " " + lname}
|
8
|
+
|
9
|
+
.demo2= yield_content :demo2, "Johnny", "Smith"
|
10
|
+
|
11
|
+
.demo_has_content= content_for?(:demo)
|
12
|
+
.fake_has_content= content_for?(:fake)
|
13
|
+
|
14
|
+
- content_for :demo3 do
|
15
|
+
%p{:class => "duplication"} One
|
16
|
+
- content_for :demo3, :flush => true do
|
17
|
+
%p{:class => "duplication"} Two
|
18
|
+
|
19
|
+
.demo3= yield_content :demo3
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- content_for :demo do
|
2
|
+
h1 This is content yielded from a content_for
|
3
|
+
|
4
|
+
.demo= yield_content :demo
|
5
|
+
|
6
|
+
- content_for :demo2 do |fname, lname|
|
7
|
+
h1 This is content yielded with name #{fname + " " + lname}
|
8
|
+
|
9
|
+
.demo2= yield_content :demo2, "Johnny", "Smith"
|
10
|
+
|
11
|
+
.demo_has_content= content_for?(:demo)
|
12
|
+
.fake_has_content= content_for?(:fake)
|
13
|
+
|
14
|
+
- content_for :demo3 do
|
15
|
+
p.duplication One
|
16
|
+
- content_for :demo3, :flush => true do
|
17
|
+
p.duplication Two
|
18
|
+
|
19
|
+
.demo3= yield_content :demo3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= content_tag :p, "Test 1", :class => 'test', :id => "test1" %>
|
2
|
+
|
3
|
+
<%= content_tag :p, "Test 2" %>
|
4
|
+
|
5
|
+
<% content_tag(:p, :class => 'test', :id => 'test3') do %>
|
6
|
+
<span>Test 3</span>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_tag(:p) do %>
|
10
|
+
<span>Test 4</span>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%= content_tag_with_block %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% @user = MarkupUser.new %>
|
2
|
+
<% form_for @user , '/demo1', :id => 'demo-fields-for' do |f| %>
|
3
|
+
<%= f.text_field :gender %>
|
4
|
+
<% fields_for @user.permission do |permission| %>
|
5
|
+
<%= permission.check_box :can_edit %>
|
6
|
+
<%= permission.check_box :can_delete %>
|
7
|
+
<% end %>
|
8
|
+
<% f.fields_for :telephone do |child_form| %>
|
9
|
+
<%= child_form.label :number %>
|
10
|
+
<%= child_form.text_field :number %>
|
11
|
+
<% end %>
|
12
|
+
<% f.fields_for :addresses do |child_form| %>
|
13
|
+
<%= child_form.label :name %>
|
14
|
+
<%= child_form.text_field :name %>
|
15
|
+
<% unless child_form.object.new_record? %>
|
16
|
+
<%= child_form.check_box '_destroy' %>
|
17
|
+
<%= child_form.label '_destroy', :caption => 'Remove' %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- @user = MarkupUser.new
|
2
|
+
= form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
|
3
|
+
= f.text_field :gender
|
4
|
+
= fields_for @user.permission do |permission|
|
5
|
+
= permission.check_box :can_edit
|
6
|
+
= permission.check_box :can_delete
|
7
|
+
= f.fields_for :telephone do |child_form|
|
8
|
+
= child_form.label :number
|
9
|
+
= child_form.text_field :number
|
10
|
+
= f.fields_for :addresses do |child_form|
|
11
|
+
= child_form.label :name
|
12
|
+
= child_form.text_field :name
|
13
|
+
- unless child_form.object.new_record?
|
14
|
+
= child_form.check_box '_destroy'
|
15
|
+
= child_form.label '_destroy', :caption => 'Remove'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- @user = MarkupUser.new
|
2
|
+
= form_for @user , '/demo1', :id => 'demo-fields-for' do |f|
|
3
|
+
= f.text_field :gender
|
4
|
+
= fields_for @user.permission do |permission|
|
5
|
+
= permission.check_box :can_edit
|
6
|
+
= permission.check_box :can_delete
|
7
|
+
= f.fields_for :telephone do |child_form|
|
8
|
+
= child_form.label :number
|
9
|
+
= child_form.text_field :number
|
10
|
+
= f.fields_for :addresses do |child_form|
|
11
|
+
= child_form.label :name
|
12
|
+
= child_form.text_field :name
|
13
|
+
- unless child_form.object.new_record?
|
14
|
+
= child_form.check_box '_destroy'
|
15
|
+
= child_form.label '_destroy', :caption => 'Remove'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% form_for MarkupUser.new, '/demo', :id => 'demo' do |f| %>
|
2
|
+
<%= f.error_messages(:header_message => "custom MarkupUser cannot be saved!") %>
|
3
|
+
<%= f.hidden_field :session_id %>
|
4
|
+
<p>
|
5
|
+
<%= f.label :username, :caption => "Login: ", :class => 'user-label' %>
|
6
|
+
<%= f.text_field :username, :class => 'user-text', :value => "John" %>
|
7
|
+
</p>
|
8
|
+
<p>
|
9
|
+
<%= f.label :password %>
|
10
|
+
<%= f.password_field :password, :class => 'user-password', :value => "secret" %>
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<%= f.label :age %>
|
14
|
+
<%= f.number_field :age, :class => 'numeric '%>
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<%= f.label :telephone %>
|
18
|
+
<%= f.telephone_field :telephone, :class => 'numeric' %>
|
19
|
+
</p>
|
20
|
+
<p>
|
21
|
+
<%= f.label :email, :caption => 'Email Address: ' %>
|
22
|
+
<%= f.email_field :email, :class => 'string' %>
|
23
|
+
</p>
|
24
|
+
<p>
|
25
|
+
<%= f.label :webpage, :caption => 'Your Web Page: ' %>
|
26
|
+
<%= f.url_field :webpage, :class => 'string' %>
|
27
|
+
</p>
|
28
|
+
<p>
|
29
|
+
<%= f.label :search %>
|
30
|
+
<%= f.search_field :search, :class => 'string' %>
|
31
|
+
</p>
|
32
|
+
<p>
|
33
|
+
<%= f.label :photo %>
|
34
|
+
<%= f.file_field :photo, :class => 'user-photo' %>
|
35
|
+
</p>
|
36
|
+
<p>
|
37
|
+
<%= f.label :about, :caption => "About Me: " %>
|
38
|
+
<%= f.text_area :about, :class => 'user-about' %>
|
39
|
+
</p>
|
40
|
+
<p>
|
41
|
+
<%= f.label :gender, :caption => "Your gender: " %>
|
42
|
+
<%= f.radio_button :gender, :value => 'male' %>
|
43
|
+
<%= f.radio_button :gender, :value => 'female' %>
|
44
|
+
</p>
|
45
|
+
<p>
|
46
|
+
<%= f.label :country, :caption => "Your country" %>
|
47
|
+
<%= f.select :country, :options => ['USA', 'Canada', 'Mexico'], :selected => 'USA', :class => 'selector' %>
|
48
|
+
</p>
|
49
|
+
<p>
|
50
|
+
<%= f.label :remember_me %>
|
51
|
+
<%= f.check_box :remember_me, :value => '1' %>
|
52
|
+
</p>
|
53
|
+
<p><%= f.submit "Create", :class => 'success', :id => 'demo-button' %></p>
|
54
|
+
<p><%= f.image_submit "buttons/post.png", :class => 'success', :id => 'image-button' %></p>
|
55
|
+
<% end %>
|
56
|
+
|
57
|
+
<% form_for MarkupUser.new, '/another_demo', :id => 'demo2', :method => 'get' do |f| %>
|
58
|
+
<%= f.error_messages :header_message => "custom MarkupUser cannot be saved!" %>
|
59
|
+
<%= f.hidden_field :session_id %>
|
60
|
+
<%= f.text_field_block :username, { :class => 'input' }, { :caption => 'Nickname: ', :class => 'label' } %>
|
61
|
+
<%= f.password_field_block :code, { :class => 'input' } %>
|
62
|
+
<%= f.text_area_block :about, { :class => 'textarea' } %>
|
63
|
+
<%= f.file_field_block :photo, { :class => 'upload' } %>
|
64
|
+
<%= f.check_box_block :remember_me, { :class => 'checker' } %>
|
65
|
+
<%= f.select_block :state, :options => ['California', 'Texas'], :class => 'selector' %>
|
66
|
+
<%= f.submit_block "Create", { :class => 'button' } %>
|
67
|
+
<%= f.image_submit_block "buttons/ok.png", { :class => 'image' } %>
|
68
|
+
<% end %>
|
69
|
+
|
70
|
+
<% form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f| %>
|
71
|
+
<%= f.text_field_block :username %>
|
72
|
+
<% end %>
|