slim 1.3.9 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -8
- data/.travis.yml +8 -7
- data/CHANGES +35 -0
- data/Gemfile +9 -9
- data/README.md +94 -176
- data/Rakefile +7 -14
- data/benchmarks/run-benchmarks.rb +9 -37
- data/doc/logic_less.md +140 -0
- data/doc/translator.md +31 -0
- data/lib/slim.rb +3 -1
- data/lib/slim/code_attributes.rb +20 -20
- data/lib/slim/command.rb +16 -6
- data/lib/slim/do_inserter.rb +33 -0
- data/lib/slim/embedded.rb +0 -6
- data/lib/slim/end_inserter.rb +2 -2
- data/lib/slim/engine.rb +9 -23
- data/lib/slim/erb_converter.rb +14 -0
- data/lib/slim/filter.rb +2 -2
- data/lib/slim/logic_less/context.rb +8 -0
- data/lib/slim/logic_less/filter.rb +12 -11
- data/lib/slim/parser.rb +57 -113
- data/lib/slim/splat/builder.rb +79 -0
- data/lib/slim/splat/filter.rb +93 -0
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -1
- data/test/core/helper.rb +1 -3
- data/test/core/test_code_blocks.rb +51 -0
- data/test/core/test_code_evaluation.rb +4 -12
- data/test/core/test_embedded_engines.rb +18 -44
- data/test/core/test_encoding.rb +8 -1
- data/test/core/test_erb_converter.rb +67 -0
- data/test/core/test_html_attributes.rb +19 -25
- data/test/core/test_html_escaping.rb +10 -2
- data/test/core/test_html_structure.rb +6 -6
- data/test/core/test_parser_errors.rb +1 -1
- data/test/core/test_ruby_errors.rb +2 -6
- data/test/core/test_thread_options.rb +4 -4
- data/test/core/test_unicode.rb +18 -0
- data/test/literate/TESTS.md +193 -34
- data/test/logic_less/test_logic_less.rb +17 -0
- data/test/rails/app/controllers/application_controller.rb +0 -1
- data/test/rails/app/controllers/entries_controller.rb +5 -0
- data/test/rails/app/controllers/slim_controller.rb +3 -0
- data/test/rails/app/models/entry.rb +16 -0
- data/test/rails/app/views/entries/edit.html.slim +3 -0
- data/test/rails/app/views/slim/form_for.html.slim +2 -0
- data/test/rails/app/views/slim/xml.slim +1 -0
- data/test/rails/config/application.rb +2 -2
- data/test/rails/config/environments/test.rb +1 -1
- data/test/rails/config/routes.rb +1 -1
- data/test/rails/test/helper.rb +0 -3
- data/test/rails/test/test_slim.rb +13 -8
- data/test/translator/test_translator.rb +13 -2
- metadata +17 -14
- data/lib/slim/splat_attributes.rb +0 -113
- data/test/rails/app/controllers/parents_controller.rb +0 -85
- data/test/rails/app/models/child.rb +0 -3
- data/test/rails/app/models/parent.rb +0 -4
- data/test/rails/app/views/parents/_form.html.slim +0 -8
- data/test/rails/app/views/parents/edit.html.slim +0 -2
- data/test/rails/app/views/parents/new.html.slim +0 -2
- data/test/rails/app/views/parents/show.html.slim +0 -5
- data/test/rails/config/database.yml +0 -4
- data/test/rails/db/migrate/20101220223037_parents_and_children.rb +0 -17
@@ -133,6 +133,23 @@ p
|
|
133
133
|
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, :scope => object, :dictionary_access => :instance_variable
|
134
134
|
end
|
135
135
|
|
136
|
+
def test_to_s_access
|
137
|
+
source = %q{
|
138
|
+
p
|
139
|
+
- people
|
140
|
+
.name = self
|
141
|
+
}
|
142
|
+
|
143
|
+
hash = {
|
144
|
+
:people => [
|
145
|
+
'Joe',
|
146
|
+
'Jack'
|
147
|
+
]
|
148
|
+
}
|
149
|
+
|
150
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, :scope => hash, :dictionary_access => :symbol
|
151
|
+
end
|
152
|
+
|
136
153
|
def test_string_hash
|
137
154
|
source = %q{
|
138
155
|
p
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Entry
|
2
|
+
include ActiveModel::Conversion
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
attributes.each do |name, value|
|
9
|
+
send("#{name}=", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def persisted?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
h1 Hello Slim!
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
3
|
require 'active_model/railtie'
|
4
|
-
require 'active_record/railtie'
|
5
4
|
require 'action_controller/railtie'
|
6
5
|
require 'action_view/railtie'
|
7
|
-
require '
|
6
|
+
#require 'active_record/railtie'
|
7
|
+
#require 'action_mailer/railtie'
|
8
8
|
|
9
9
|
require 'slim'
|
10
10
|
|
@@ -20,7 +20,7 @@ Dummy::Application.configure do
|
|
20
20
|
# Tell Action Mailer not to deliver emails to the real world.
|
21
21
|
# The :test delivery method accumulates sent emails in the
|
22
22
|
# ActionMailer::Base.deliveries array.
|
23
|
-
config.action_mailer.delivery_method = :test
|
23
|
+
#config.action_mailer.delivery_method = :test
|
24
24
|
|
25
25
|
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
26
26
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
data/test/rails/config/routes.rb
CHANGED
data/test/rails/test/helper.rb
CHANGED
@@ -9,6 +9,14 @@ class TestSlim < ActionDispatch::IntegrationTest
|
|
9
9
|
assert_html "<h1>Hello Slim!</h1>"
|
10
10
|
end
|
11
11
|
|
12
|
+
test "xml view" do
|
13
|
+
get "slim/xml"
|
14
|
+
assert_response :success
|
15
|
+
assert_template "slim/xml"
|
16
|
+
assert_template "layouts/application"
|
17
|
+
assert_html "<h1>Hello Slim!</h1>"
|
18
|
+
end
|
19
|
+
|
12
20
|
test "normal erb view" do
|
13
21
|
get "slim/erb"
|
14
22
|
assert_html "<h1>Hello Erb!</h1>"
|
@@ -58,14 +66,11 @@ class TestSlim < ActionDispatch::IntegrationTest
|
|
58
66
|
assert_html "<p>Page content</p><h1><p>Hello Slim!</p></h1><h2><p>Hello Slim!</p></h2>", :heading => 'Heading set from a view'
|
59
67
|
end
|
60
68
|
|
61
|
-
test "
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert_match %r{
|
66
|
-
assert_match %r{<input id="parent_name" name="parent\[name\]"}, @response.body
|
67
|
-
assert_match %r{<input id="parent_children_attributes_0_name" name="parent\[children_attributes\]\[0\]\[name\]"}, @response.body
|
68
|
-
assert_match %r{<input id="parent_children_attributes_0_id" name="parent\[children_attributes\]\[0\]\[id\]"}, @response.body
|
69
|
+
test "form_for" do
|
70
|
+
get "entries/edit/1"
|
71
|
+
assert_match %r{action="/entries"}, @response.body
|
72
|
+
assert_match %r{<label><b>Name</b></label>}, @response.body
|
73
|
+
assert_match %r{<input id="entry_name" name="entry\[name\]"}, @response.body
|
69
74
|
end
|
70
75
|
|
71
76
|
protected
|
@@ -26,8 +26,19 @@ markdown:
|
|
26
26
|
* one
|
27
27
|
* two
|
28
28
|
}
|
29
|
-
|
30
|
-
|
29
|
+
if !Gem::Specification::find_all_by_name('redcarpet').empty?
|
30
|
+
# redcarpet
|
31
|
+
assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source, :tr_mode => :dynamic
|
32
|
+
assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", source, :tr_mode => :static
|
33
|
+
elsif !Gem::Specification::find_all_by_name('rdiscount').empty?
|
34
|
+
# rdiscount
|
35
|
+
assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source, :tr_mode => :dynamic
|
36
|
+
assert_html "<h1>Header</h1>\n\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n\n", source, :tr_mode => :static
|
37
|
+
else
|
38
|
+
# kramdown
|
39
|
+
assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n <li>one</li>\n <li>two</li>\n</ul>\n", source, :tr_mode => :dynamic
|
40
|
+
assert_html "<h1 id=\"header\">Header</h1>\n<p>Hello from Markdown!</p>\n\n<p>3</p>\n\n<ul>\n <li>one</li>\n <li>two</li>\n</ul>\n", source, :tr_mode => :static
|
41
|
+
end
|
31
42
|
end
|
32
43
|
|
33
44
|
def test_no_translation_of_attrs
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Mendler
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: temple
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.6.
|
21
|
+
version: 0.6.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.6.
|
28
|
+
version: 0.6.5
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: tilt
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,14 +74,18 @@ files:
|
|
74
74
|
- benchmarks/view.haml
|
75
75
|
- benchmarks/view.slim
|
76
76
|
- bin/slimrb
|
77
|
+
- doc/logic_less.md
|
78
|
+
- doc/translator.md
|
77
79
|
- kill-travis.sh
|
78
80
|
- lib/slim.rb
|
79
81
|
- lib/slim/code_attributes.rb
|
80
82
|
- lib/slim/command.rb
|
81
83
|
- lib/slim/controls.rb
|
84
|
+
- lib/slim/do_inserter.rb
|
82
85
|
- lib/slim/embedded.rb
|
83
86
|
- lib/slim/end_inserter.rb
|
84
87
|
- lib/slim/engine.rb
|
88
|
+
- lib/slim/erb_converter.rb
|
85
89
|
- lib/slim/filter.rb
|
86
90
|
- lib/slim/grammar.rb
|
87
91
|
- lib/slim/interpolation.rb
|
@@ -89,7 +93,8 @@ files:
|
|
89
93
|
- lib/slim/logic_less/context.rb
|
90
94
|
- lib/slim/logic_less/filter.rb
|
91
95
|
- lib/slim/parser.rb
|
92
|
-
- lib/slim/
|
96
|
+
- lib/slim/splat/builder.rb
|
97
|
+
- lib/slim/splat/filter.rb
|
93
98
|
- lib/slim/template.rb
|
94
99
|
- lib/slim/translator.rb
|
95
100
|
- lib/slim/version.rb
|
@@ -102,6 +107,7 @@ files:
|
|
102
107
|
- test/core/test_code_structure.rb
|
103
108
|
- test/core/test_embedded_engines.rb
|
104
109
|
- test/core/test_encoding.rb
|
110
|
+
- test/core/test_erb_converter.rb
|
105
111
|
- test/core/test_html_attributes.rb
|
106
112
|
- test/core/test_html_escaping.rb
|
107
113
|
- test/core/test_html_structure.rb
|
@@ -112,35 +118,33 @@ files:
|
|
112
118
|
- test/core/test_tabs.rb
|
113
119
|
- test/core/test_text_interpolation.rb
|
114
120
|
- test/core/test_thread_options.rb
|
121
|
+
- test/core/test_unicode.rb
|
115
122
|
- test/literate/TESTS.md
|
116
123
|
- test/literate/helper.rb
|
117
124
|
- test/literate/run.rb
|
118
125
|
- test/logic_less/test_logic_less.rb
|
119
126
|
- test/rails/Rakefile
|
120
127
|
- test/rails/app/controllers/application_controller.rb
|
121
|
-
- test/rails/app/controllers/
|
128
|
+
- test/rails/app/controllers/entries_controller.rb
|
122
129
|
- test/rails/app/controllers/slim_controller.rb
|
123
130
|
- test/rails/app/helpers/application_helper.rb
|
124
|
-
- test/rails/app/models/
|
125
|
-
- test/rails/app/
|
131
|
+
- test/rails/app/models/entry.rb
|
132
|
+
- test/rails/app/views/entries/edit.html.slim
|
126
133
|
- test/rails/app/views/layouts/application.html.slim
|
127
|
-
- test/rails/app/views/parents/_form.html.slim
|
128
|
-
- test/rails/app/views/parents/edit.html.slim
|
129
|
-
- test/rails/app/views/parents/new.html.slim
|
130
|
-
- test/rails/app/views/parents/show.html.slim
|
131
134
|
- test/rails/app/views/slim/_partial.html.slim
|
132
135
|
- test/rails/app/views/slim/content_for.html.slim
|
133
136
|
- test/rails/app/views/slim/erb.html.erb
|
137
|
+
- test/rails/app/views/slim/form_for.html.slim
|
134
138
|
- test/rails/app/views/slim/integers.html.slim
|
135
139
|
- test/rails/app/views/slim/no_layout.html.slim
|
136
140
|
- test/rails/app/views/slim/normal.html.slim
|
137
141
|
- test/rails/app/views/slim/partial.html.slim
|
138
142
|
- test/rails/app/views/slim/thread_options.html.slim
|
139
143
|
- test/rails/app/views/slim/variables.html.slim
|
144
|
+
- test/rails/app/views/slim/xml.slim
|
140
145
|
- test/rails/config.ru
|
141
146
|
- test/rails/config/application.rb
|
142
147
|
- test/rails/config/boot.rb
|
143
|
-
- test/rails/config/database.yml
|
144
148
|
- test/rails/config/environment.rb
|
145
149
|
- test/rails/config/environments/test.rb
|
146
150
|
- test/rails/config/initializers/backtrace_silencers.rb
|
@@ -150,7 +154,6 @@ files:
|
|
150
154
|
- test/rails/config/initializers/session_store.rb
|
151
155
|
- test/rails/config/locales/en.yml
|
152
156
|
- test/rails/config/routes.rb
|
153
|
-
- test/rails/db/migrate/20101220223037_parents_and_children.rb
|
154
157
|
- test/rails/script/rails
|
155
158
|
- test/rails/test/helper.rb
|
156
159
|
- test/rails/test/test_slim.rb
|
@@ -1,113 +0,0 @@
|
|
1
|
-
module Slim
|
2
|
-
# @api private
|
3
|
-
class SplatAttributes < Filter
|
4
|
-
define_options :sort_attrs, :default_tag, :merge_attrs, :attr_quote
|
5
|
-
|
6
|
-
def call(exp)
|
7
|
-
@merge_attrs, @splat_used = unique_name, false
|
8
|
-
exp = compile(exp)
|
9
|
-
if @splat_used
|
10
|
-
[:multi, [:code, "#{@merge_attrs} = #{@options[:merge_attrs].inspect}"], exp]
|
11
|
-
else
|
12
|
-
exp
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Handle tag expression `[:html, :tag, name, attrs, content]`
|
17
|
-
#
|
18
|
-
# @param [String] name Tag name
|
19
|
-
# @param [Array] attrs Temple expression
|
20
|
-
# @param [Array] content Temple expression
|
21
|
-
# @return [Array] Compiled temple expression
|
22
|
-
def on_html_tag(name, attrs, content = nil)
|
23
|
-
return super if name != '*'
|
24
|
-
hash, merger, formatter = splat_attributes(attrs[2..-1])
|
25
|
-
tmp = unique_name
|
26
|
-
tag = [:multi,
|
27
|
-
merger,
|
28
|
-
[:code, "#{tmp} = #{hash}.delete('tag').to_s"],
|
29
|
-
[:if, "#{tmp}.empty?",
|
30
|
-
[:code, "#{tmp} = #{@options[:default_tag].inspect}"]],
|
31
|
-
[:static, '<'],
|
32
|
-
[:dynamic, "#{tmp}"],
|
33
|
-
formatter]
|
34
|
-
tag << if content
|
35
|
-
[:multi,
|
36
|
-
[:static, '>'],
|
37
|
-
compile(content),
|
38
|
-
[:static, '</'],
|
39
|
-
[:dynamic, "#{tmp}"],
|
40
|
-
[:static, '>']]
|
41
|
-
else
|
42
|
-
[:static, '/>']
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Handle attributes expression `[:html, :attrs, *attrs]`
|
47
|
-
#
|
48
|
-
# @param [Array] attrs Array of temple expressions
|
49
|
-
# @return [Array] Compiled temple expression
|
50
|
-
def on_html_attrs(*attrs)
|
51
|
-
return super if attrs.all? {|attr| attr[1] != :splat}
|
52
|
-
hash, merger, formatter = splat_attributes(attrs)
|
53
|
-
[:multi, merger, formatter]
|
54
|
-
end
|
55
|
-
|
56
|
-
protected
|
57
|
-
|
58
|
-
def splat_attributes(attrs)
|
59
|
-
@splat_used = true
|
60
|
-
|
61
|
-
hash, name, value, tmp = unique_name, unique_name, unique_name, unique_name
|
62
|
-
|
63
|
-
merger = [:multi, [:code, "#{hash} = {}"]]
|
64
|
-
attrs.each do |attr|
|
65
|
-
merger << if attr[0] == :html && attr[1] == :attr
|
66
|
-
[:multi,
|
67
|
-
[:capture, tmp, compile(attr[3])],
|
68
|
-
[:code, "(#{hash}[#{attr[2].inspect}] ||= []) << #{tmp}"]]
|
69
|
-
elsif attr[0] == :slim
|
70
|
-
if attr[1] == :attr
|
71
|
-
[:code, "(#{hash}[#{attr[2].inspect}] ||= []) << (#{attr[4]})"]
|
72
|
-
elsif attr[1] == :splat
|
73
|
-
[:code, "(#{attr[2]}).each {|#{name},#{value}| (#{hash}[#{name}.to_s] ||= []) << (#{value}) }"]
|
74
|
-
else
|
75
|
-
attr
|
76
|
-
end
|
77
|
-
else
|
78
|
-
attr
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
merger << [:block, "#{hash}.keys.each do |#{name}|",
|
83
|
-
[:multi,
|
84
|
-
[:code, "#{value} = #{hash}[#{name}]"],
|
85
|
-
[:if, "#{@merge_attrs}[#{name}]",
|
86
|
-
[:multi,
|
87
|
-
[:code, "#{value}.flatten!"],
|
88
|
-
[:code, "#{value}.map!(&:to_s)"],
|
89
|
-
[:code, "#{value}.reject!(&:empty?)"],
|
90
|
-
[:if, "#{value}.empty?",
|
91
|
-
[:code, "#{hash}.delete(#{name})"],
|
92
|
-
[:code, "#{hash}[#{name}] = #{value}.join(#{@merge_attrs}[#{name}].to_s)"]]],
|
93
|
-
[:multi,
|
94
|
-
[:if, "#{value}.size > 1",
|
95
|
-
[:code, %{raise("Multiple #\{#{name}\} attributes specified")}]],
|
96
|
-
[:case, "#{value}.first",
|
97
|
-
['true', [:code, "#{hash}[#{name}] = #{name}"]],
|
98
|
-
['false, nil', [:code, "#{hash}.delete(#{name})"]],
|
99
|
-
[:else, [:code, "#{hash}[#{name}] = #{value}.first"]]]]]]]
|
100
|
-
|
101
|
-
attr = [:multi,
|
102
|
-
[:static, ' '],
|
103
|
-
[:dynamic, name],
|
104
|
-
[:static, "=#{options[:attr_quote]}"],
|
105
|
-
[:escape, true, [:dynamic, value]],
|
106
|
-
[:static, options[:attr_quote]]]
|
107
|
-
enumerator = options[:sort_attrs] ? "#{hash}.sort_by {|#{name},#{value}| #{name} }" : hash
|
108
|
-
formatter = [:block, "#{enumerator}.each do |#{name},#{value}|", attr]
|
109
|
-
|
110
|
-
return hash, merger, formatter
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
class ParentsController < ApplicationController
|
2
|
-
# GET /parents
|
3
|
-
# GET /parents.xml
|
4
|
-
def index
|
5
|
-
@parents = Parent.all
|
6
|
-
|
7
|
-
respond_to do |format|
|
8
|
-
format.html # index.html.erb
|
9
|
-
format.xml { render :xml => @parents }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /parents/1
|
14
|
-
# GET /parents/1.xml
|
15
|
-
def show
|
16
|
-
@parent = Parent.find(params[:id])
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.html # show.html.erb
|
20
|
-
format.xml { render :xml => @parent }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# GET /parents/new
|
25
|
-
# GET /parents/new.xml
|
26
|
-
def new
|
27
|
-
@parent = Parent.new
|
28
|
-
@parent.children.build
|
29
|
-
|
30
|
-
respond_to do |format|
|
31
|
-
format.html # new.html.erb
|
32
|
-
format.xml { render :xml => @parent }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# GET /parents/1/edit
|
37
|
-
def edit
|
38
|
-
@parent = Parent.find(params[:id])
|
39
|
-
end
|
40
|
-
|
41
|
-
# POST /parents
|
42
|
-
# POST /parents.xml
|
43
|
-
def create
|
44
|
-
params.permit! if params.respond_to? :permit!
|
45
|
-
@parent = Parent.new(params[:parent])
|
46
|
-
|
47
|
-
respond_to do |format|
|
48
|
-
if @parent.save
|
49
|
-
format.html { redirect_to(@parent, :notice => 'Parent was successfully created.') }
|
50
|
-
format.xml { render :xml => @parent, :status => :created, :location => @parent }
|
51
|
-
else
|
52
|
-
format.html { render :action => "new" }
|
53
|
-
format.xml { render :xml => @parent.errors, :status => :unprocessable_entity }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# PUT /parents/1
|
59
|
-
# PUT /parents/1.xml
|
60
|
-
def update
|
61
|
-
@parent = Parent.find(params[:id])
|
62
|
-
|
63
|
-
respond_to do |format|
|
64
|
-
if @parent.update_attributes(params[:parent])
|
65
|
-
format.html { redirect_to(@parent, :notice => 'Parent was successfully updated.') }
|
66
|
-
format.xml { head :ok }
|
67
|
-
else
|
68
|
-
format.html { render :action => "edit" }
|
69
|
-
format.xml { render :xml => @parent.errors, :status => :unprocessable_entity }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# DELETE /parents/1
|
75
|
-
# DELETE /parents/1.xml
|
76
|
-
def destroy
|
77
|
-
@parent = Parent.find(params[:id])
|
78
|
-
@parent.destroy
|
79
|
-
|
80
|
-
respond_to do |format|
|
81
|
-
format.html { redirect_to(parents_url) }
|
82
|
-
format.xml { head :ok }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|