actionview 4.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +274 -0
  3. data/MIT-LICENSE +21 -0
  4. data/README.rdoc +34 -0
  5. data/lib/action_view.rb +97 -0
  6. data/lib/action_view/base.rb +205 -0
  7. data/lib/action_view/buffers.rb +49 -0
  8. data/lib/action_view/context.rb +36 -0
  9. data/lib/action_view/dependency_tracker.rb +93 -0
  10. data/lib/action_view/digestor.rb +116 -0
  11. data/lib/action_view/flows.rb +76 -0
  12. data/lib/action_view/helpers.rb +64 -0
  13. data/lib/action_view/helpers/active_model_helper.rb +49 -0
  14. data/lib/action_view/helpers/asset_tag_helper.rb +322 -0
  15. data/lib/action_view/helpers/asset_url_helper.rb +355 -0
  16. data/lib/action_view/helpers/atom_feed_helper.rb +203 -0
  17. data/lib/action_view/helpers/cache_helper.rb +200 -0
  18. data/lib/action_view/helpers/capture_helper.rb +216 -0
  19. data/lib/action_view/helpers/controller_helper.rb +25 -0
  20. data/lib/action_view/helpers/csrf_helper.rb +30 -0
  21. data/lib/action_view/helpers/date_helper.rb +1075 -0
  22. data/lib/action_view/helpers/debug_helper.rb +39 -0
  23. data/lib/action_view/helpers/form_helper.rb +1876 -0
  24. data/lib/action_view/helpers/form_options_helper.rb +843 -0
  25. data/lib/action_view/helpers/form_tag_helper.rb +746 -0
  26. data/lib/action_view/helpers/javascript_helper.rb +75 -0
  27. data/lib/action_view/helpers/number_helper.rb +425 -0
  28. data/lib/action_view/helpers/output_safety_helper.rb +38 -0
  29. data/lib/action_view/helpers/record_tag_helper.rb +108 -0
  30. data/lib/action_view/helpers/rendering_helper.rb +90 -0
  31. data/lib/action_view/helpers/sanitize_helper.rb +256 -0
  32. data/lib/action_view/helpers/tag_helper.rb +176 -0
  33. data/lib/action_view/helpers/tags.rb +41 -0
  34. data/lib/action_view/helpers/tags/base.rb +148 -0
  35. data/lib/action_view/helpers/tags/check_box.rb +64 -0
  36. data/lib/action_view/helpers/tags/checkable.rb +16 -0
  37. data/lib/action_view/helpers/tags/collection_check_boxes.rb +44 -0
  38. data/lib/action_view/helpers/tags/collection_helpers.rb +85 -0
  39. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +36 -0
  40. data/lib/action_view/helpers/tags/collection_select.rb +28 -0
  41. data/lib/action_view/helpers/tags/color_field.rb +25 -0
  42. data/lib/action_view/helpers/tags/date_field.rb +13 -0
  43. data/lib/action_view/helpers/tags/date_select.rb +72 -0
  44. data/lib/action_view/helpers/tags/datetime_field.rb +22 -0
  45. data/lib/action_view/helpers/tags/datetime_local_field.rb +19 -0
  46. data/lib/action_view/helpers/tags/datetime_select.rb +8 -0
  47. data/lib/action_view/helpers/tags/email_field.rb +8 -0
  48. data/lib/action_view/helpers/tags/file_field.rb +8 -0
  49. data/lib/action_view/helpers/tags/grouped_collection_select.rb +29 -0
  50. data/lib/action_view/helpers/tags/hidden_field.rb +8 -0
  51. data/lib/action_view/helpers/tags/label.rb +65 -0
  52. data/lib/action_view/helpers/tags/month_field.rb +13 -0
  53. data/lib/action_view/helpers/tags/number_field.rb +18 -0
  54. data/lib/action_view/helpers/tags/password_field.rb +12 -0
  55. data/lib/action_view/helpers/tags/radio_button.rb +31 -0
  56. data/lib/action_view/helpers/tags/range_field.rb +8 -0
  57. data/lib/action_view/helpers/tags/search_field.rb +24 -0
  58. data/lib/action_view/helpers/tags/select.rb +41 -0
  59. data/lib/action_view/helpers/tags/tel_field.rb +8 -0
  60. data/lib/action_view/helpers/tags/text_area.rb +18 -0
  61. data/lib/action_view/helpers/tags/text_field.rb +29 -0
  62. data/lib/action_view/helpers/tags/time_field.rb +13 -0
  63. data/lib/action_view/helpers/tags/time_select.rb +8 -0
  64. data/lib/action_view/helpers/tags/time_zone_select.rb +20 -0
  65. data/lib/action_view/helpers/tags/url_field.rb +8 -0
  66. data/lib/action_view/helpers/tags/week_field.rb +13 -0
  67. data/lib/action_view/helpers/text_helper.rb +447 -0
  68. data/lib/action_view/helpers/translation_helper.rb +111 -0
  69. data/lib/action_view/helpers/url_helper.rb +625 -0
  70. data/lib/action_view/layouts.rb +426 -0
  71. data/lib/action_view/locale/en.yml +56 -0
  72. data/lib/action_view/log_subscriber.rb +44 -0
  73. data/lib/action_view/lookup_context.rb +249 -0
  74. data/lib/action_view/model_naming.rb +12 -0
  75. data/lib/action_view/path_set.rb +77 -0
  76. data/lib/action_view/railtie.rb +49 -0
  77. data/lib/action_view/record_identifier.rb +84 -0
  78. data/lib/action_view/renderer/abstract_renderer.rb +47 -0
  79. data/lib/action_view/renderer/partial_renderer.rb +492 -0
  80. data/lib/action_view/renderer/renderer.rb +50 -0
  81. data/lib/action_view/renderer/streaming_template_renderer.rb +103 -0
  82. data/lib/action_view/renderer/template_renderer.rb +96 -0
  83. data/lib/action_view/rendering.rb +145 -0
  84. data/lib/action_view/routing_url_for.rb +109 -0
  85. data/lib/action_view/tasks/dependencies.rake +17 -0
  86. data/lib/action_view/template.rb +340 -0
  87. data/lib/action_view/template/error.rb +141 -0
  88. data/lib/action_view/template/handlers.rb +53 -0
  89. data/lib/action_view/template/handlers/builder.rb +26 -0
  90. data/lib/action_view/template/handlers/erb.rb +145 -0
  91. data/lib/action_view/template/handlers/raw.rb +11 -0
  92. data/lib/action_view/template/resolver.rb +329 -0
  93. data/lib/action_view/template/text.rb +34 -0
  94. data/lib/action_view/template/types.rb +57 -0
  95. data/lib/action_view/test_case.rb +272 -0
  96. data/lib/action_view/testing/resolvers.rb +50 -0
  97. data/lib/action_view/vendor/html-scanner.rb +20 -0
  98. data/lib/action_view/vendor/html-scanner/html/document.rb +68 -0
  99. data/lib/action_view/vendor/html-scanner/html/node.rb +532 -0
  100. data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +188 -0
  101. data/lib/action_view/vendor/html-scanner/html/selector.rb +830 -0
  102. data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +107 -0
  103. data/lib/action_view/vendor/html-scanner/html/version.rb +11 -0
  104. data/lib/action_view/version.rb +11 -0
  105. data/lib/action_view/view_paths.rb +96 -0
  106. metadata +218 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e69ff5a4c30fd62beef867fc2784a150fb2257c8
4
+ data.tar.gz: 432b3ab5392319c96a5bf40c6be38732e79d9471
5
+ SHA512:
6
+ metadata.gz: 130164484e50c2478720874582fe280412e5984fde4118f7300a474a04a13c5b759b3a1eba19d1cdee37349e170379b59b09416ffaf887f6d1081cda8c43529b
7
+ data.tar.gz: 4df703381b324f9c3e85b97c095f6f41425b0322b451434f647608dbd25f9c787ca7472586d05986df199bdd8381a8d8a1452a5b8905270ce869e667c8b81299
data/CHANGELOG.md ADDED
@@ -0,0 +1,274 @@
1
+ * A Cycle object should accept an array and cycle through it as it would with a set of
2
+ comma-separated objects.
3
+
4
+ arr = [1,2,3]
5
+ cycle(arr) # => '1'
6
+ cycle(arr) # => '2'
7
+ cycle(arr) # => '3'
8
+
9
+ Previously, it would return the array as a string, because it took the array as a
10
+ single object:
11
+
12
+ arr = [1,2,3]
13
+ cycle(arr) # => '[1,2,3]'
14
+ cycle(arr) # => '[1,2,3]'
15
+ cycle(arr) # => '[1,2,3]'
16
+
17
+ *Kristian Freeman*
18
+
19
+ * Label tags generated by collection helpers only inherit the `:index` and
20
+ `:namespace` from the input, because only these attributes modifies the
21
+ `for` attribute of the label. Also, the input attributes don't have
22
+ precedence over the label attributes anymore.
23
+
24
+ Before:
25
+
26
+ collection = [[1, true, { class: 'foo' }]]
27
+ f.collection_check_boxes :options, collection, :second, :first do |b|
28
+ b.label(class: 'my_custom_class')
29
+ end
30
+
31
+ # => <label class="foo" for="user_active_true">1</label>
32
+
33
+ After:
34
+
35
+ collection = [[1, true, { class: 'foo' }]]
36
+ f.collection_check_boxes :options, collection, :second, :first do |b|
37
+ b.label(class: 'my_custom_class')
38
+ end
39
+
40
+ # => <label class="my_custom_class" for="user_active_true">1</label>
41
+
42
+ *Andriel Nuernberg*
43
+
44
+ * Fixed a long-standing bug in `json_escape` that causes quotation marks to be stripped.
45
+ This method also escapes the \u2028 and \u2029 unicode newline characters which are
46
+ treated as \n in JavaScript. This matches the behaviour of the AS::JSON encoder. (The
47
+ original change in the encoder was introduced in #10534.)
48
+
49
+ *Godfrey Chan*
50
+
51
+ * `ActionView::MissingTemplate` includes underscore when raised for a partial.
52
+
53
+ Fixes #13002.
54
+
55
+ *Yves Senn*
56
+
57
+ * Use `set_backtrace` instead of instance variable `@backtrace` in ActionView exceptions
58
+
59
+ *Shimpei Makimoto*
60
+
61
+ * Fix `simple_format` escapes own output when passing `sanitize: true`
62
+
63
+ *Paul Seidemann*
64
+
65
+ * Ensure `ActionView::Digestor.cache` is correctly cleaned up when
66
+ combining recursive templates with `ActionView::Resolver.caching = false`.
67
+
68
+ *wyaeld*
69
+
70
+ * Fix `collection_check_boxes` generated hidden input to use the name attribute provided
71
+ in the options hash.
72
+
73
+ *Angel N. Sciortino*
74
+
75
+ * Fix some edge cases for AV `select` helper with `:selected` option.
76
+
77
+ *Bogdan Gusiev*
78
+
79
+ * Ability to pass block to `select` helper
80
+
81
+ <%= select(report, "campaign_ids") do %>
82
+ <% available_campaigns.each do |c| -%>
83
+ <%= content_tag(:option, c.name, value: c.id, data: { tags: c.tags.to_json }) %>
84
+ <% end -%>
85
+ <% end -%>
86
+
87
+ *Bogdan Gusiev*
88
+
89
+ * Handle `:namespace` form option in collection labels.
90
+
91
+ *Vasiliy Ermolovich*
92
+
93
+ * Fix `form_for` when both `namespace` and `as` options are present.
94
+
95
+ `as` option no longer overwrites `namespace` option when generating
96
+ html id attribute of the form element.
97
+
98
+ *Adam Niedzielski*
99
+
100
+ * Fix `excerpt` when `:separator` is `nil`.
101
+
102
+ *Paul Nikitochkin*
103
+
104
+ * Only cache template digests if `config.cache_template_loading` is true.
105
+
106
+ *Josh Lauer*, *Justin Ridgewell*
107
+
108
+ * Fixed a bug where the lookup details were not being taken into account
109
+ when caching the digest of a template - changes to the details now
110
+ cause a different cache key to be used.
111
+
112
+ *Daniel Schierbeck*
113
+
114
+ * Added an `extname` hash option for `javascript_include_tag` method.
115
+
116
+ Before:
117
+
118
+ javascript_include_tag('templates.jst')
119
+ # => <script src="/javascripts/templates.jst.js"></script>
120
+
121
+ After:
122
+
123
+ javascript_include_tag('templates.jst', extname: false )
124
+ # => <script src="/javascripts/templates.jst"></script>
125
+
126
+ *Nathan Stitt*
127
+
128
+ * Fix `current_page?` when the URL contains escaped characters and the
129
+ original URL is using the hexadecimal lowercased.
130
+
131
+ *Rafael Mendonça França*
132
+
133
+ * Fix `text_area` to behave like `text_field` when `nil` is given as
134
+ value.
135
+
136
+ Before:
137
+
138
+ f.text_field :field, value: nil #=> <input value="">
139
+ f.text_area :field, value: nil #=> <textarea>value of field</textarea>
140
+
141
+ After:
142
+
143
+ f.text_area :field, value: nil #=> <textarea></textarea>
144
+
145
+ *Joel Cogen*
146
+
147
+ * Element of the `grouped_options_for_select` can
148
+ optionally contain html attributes as the last element of the array.
149
+
150
+ grouped_options_for_select(
151
+ [["North America", [['United States','US'],"Canada"], data: { foo: 'bar' }]]
152
+ )
153
+
154
+ *Vasiliy Ermolovich*
155
+
156
+ * Fix default rendered format problem when calling `render` without :content_type option.
157
+ It should return :html. Fix #11393.
158
+
159
+ *Gleb Mazovetskiy* *Oleg* *kennyj*
160
+
161
+ * Fix `link_to` with block and url hashes.
162
+
163
+ Before:
164
+
165
+ link_to(action: 'bar', controller: 'foo') { content_tag(:span, 'Example site') }
166
+ # => "<a action=\"bar\" controller=\"foo\"><span>Example site</span></a>"
167
+
168
+ After:
169
+
170
+ link_to(action: 'bar', controller: 'foo') { content_tag(:span, 'Example site') }
171
+ # => "<a href=\"/foo/bar\"><span>Example site</span></a>"
172
+
173
+ *Murahashi Sanemat Kenichi*
174
+
175
+ * Fix "Stack Level Too Deep" error when redering recursive partials.
176
+
177
+ Fixes #11340.
178
+
179
+ *Rafael Mendonça França*
180
+
181
+ * Added an `enforce_utf8` hash option for `form_tag` method.
182
+
183
+ Control to output a hidden input tag with name `utf8` without monkey
184
+ patching.
185
+
186
+ Before:
187
+
188
+ form_tag
189
+ # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>'
190
+
191
+ After:
192
+
193
+ form_tag
194
+ # => '<form>..<input name="utf8" type="hidden" value="&#x2713;" />..</form>'
195
+
196
+ form_tag({}, { :enforce_utf8 => false })
197
+ # => '<form>....</form>'
198
+
199
+ *ma2gedev*
200
+
201
+ * Remove the deprecated `include_seconds` argument from `distance_of_time_in_words`,
202
+ pass in an `:include_seconds` hash option to use this feature.
203
+
204
+ *Carlos Antonio da Silva*
205
+
206
+ * Remove deprecated block passing to `FormBuilder#new`.
207
+
208
+ *Vipul A M*
209
+
210
+ * Pick `DateField` `DateTimeField` and `ColorField` values from stringified options allowing use of symbol keys with helpers.
211
+
212
+ *Jon Rowe*
213
+
214
+ * Remove the deprecated `prompt` argument from `grouped_options_for_select`,
215
+ pass in a `:prompt` hash option to use this feature.
216
+
217
+ *kennyj*
218
+
219
+ * Always escape the result of `link_to_unless` method.
220
+
221
+ Before:
222
+
223
+ link_to_unless(true, '<b>Showing</b>', 'github.com')
224
+ # => "<b>Showing</b>"
225
+
226
+ After:
227
+
228
+ link_to_unless(true, '<b>Showing</b>', 'github.com')
229
+ # => "&lt;b&gt;Showing&lt;/b&gt;"
230
+
231
+ *dtaniwaki*
232
+
233
+ * Use a case insensitive URI Regexp for #asset_path.
234
+
235
+ This fix a problem where the same asset path using different case are generating
236
+ different URIs.
237
+
238
+ Before:
239
+
240
+ image_tag("HTTP://google.com")
241
+ # => "<img alt=\"Google\" src=\"/assets/HTTP://google.com\" />"
242
+ image_tag("http://google.com")
243
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
244
+
245
+ After:
246
+
247
+ image_tag("HTTP://google.com")
248
+ # => "<img alt=\"Google\" src=\"HTTP://google.com\" />"
249
+ image_tag("http://google.com")
250
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
251
+
252
+ *David Celis*
253
+
254
+ * Element of the `collection_check_boxes` and `collection_radio_buttons` can
255
+ optionally contain html attributes as the last element of the array.
256
+
257
+ *Vasiliy Ermolovich*
258
+
259
+ * Update the HTML `BOOLEAN_ATTRIBUTES` in `ActionView::Helpers::TagHelper`
260
+ to conform to the latest HTML 5.1 spec. Add attributes `allowfullscreen`,
261
+ `default`, `inert`, `sortable`, `truespeed`, `typemustmatch`. Fix attribute
262
+ `seamless` (previously misspelled `seemless`).
263
+
264
+ *Alex Peattie*
265
+
266
+ * Fix an issue where partials with a number in the filename weren't being digested for cache dependencies.
267
+
268
+ *Bryan Ricker*
269
+
270
+ * First release, ActionView extracted from ActionPack
271
+
272
+ *Piotr Sarnacki*, *Łukasz Strzałkowski*
273
+
274
+ Please check [4-0-stable (ActionPack's CHANGELOG)](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes.
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2004-2013 David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.rdoc ADDED
@@ -0,0 +1,34 @@
1
+ = Action View
2
+
3
+ Action View is a framework for handling view template lookup and rendering, and provides
4
+ view helpers that assist when building HTML forms, Atom feeds and more.
5
+ Template formats that Action View handles are ERB (embedded Ruby, typically
6
+ used to inline short Ruby snippets inside HTML), and XML Builder.
7
+
8
+ == Download and installation
9
+
10
+ The latest version of Action View can be installed with RubyGems:
11
+
12
+ % [sudo] gem install actionview
13
+
14
+ Source code can be downloaded as part of the Rails project on GitHub
15
+
16
+ * https://github.com/rails/rails/tree/master/actionview
17
+
18
+
19
+ == License
20
+
21
+ Action View is released under the MIT license:
22
+
23
+ * http://www.opensource.org/licenses/MIT
24
+
25
+
26
+ == Support
27
+
28
+ API documentation is at
29
+
30
+ * http://api.rubyonrails.org
31
+
32
+ Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
33
+
34
+ * https://github.com/rails/rails/issues
@@ -0,0 +1,97 @@
1
+ #--
2
+ # Copyright (c) 2004-2013 David Heinemeier Hansson
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'active_support'
25
+ require 'active_support/rails'
26
+
27
+ module ActionView
28
+ extend ActiveSupport::Autoload
29
+
30
+ eager_autoload do
31
+ autoload :Base
32
+ autoload :Context
33
+ autoload :CompiledTemplates, "action_view/context"
34
+ autoload :Digestor
35
+ autoload :Helpers
36
+ autoload :LookupContext
37
+ autoload :Layouts
38
+ autoload :PathSet
39
+ autoload :RecordIdentifier
40
+ autoload :Rendering
41
+ autoload :RoutingUrlFor
42
+ autoload :Template
43
+ autoload :ViewPaths
44
+
45
+ autoload_under "renderer" do
46
+ autoload :Renderer
47
+ autoload :AbstractRenderer
48
+ autoload :PartialRenderer
49
+ autoload :TemplateRenderer
50
+ autoload :StreamingTemplateRenderer
51
+ end
52
+
53
+ autoload_at "action_view/template/resolver" do
54
+ autoload :Resolver
55
+ autoload :PathResolver
56
+ autoload :FileSystemResolver
57
+ autoload :OptimizedFileSystemResolver
58
+ autoload :FallbackFileSystemResolver
59
+ end
60
+
61
+ autoload_at "action_view/buffers" do
62
+ autoload :OutputBuffer
63
+ autoload :StreamingBuffer
64
+ end
65
+
66
+ autoload_at "action_view/flows" do
67
+ autoload :OutputFlow
68
+ autoload :StreamingFlow
69
+ end
70
+
71
+ autoload_at "action_view/template/error" do
72
+ autoload :MissingTemplate
73
+ autoload :ActionViewError
74
+ autoload :EncodingError
75
+ autoload :MissingRequestError
76
+ autoload :TemplateError
77
+ autoload :WrongEncodingError
78
+ end
79
+ end
80
+
81
+ autoload :TestCase
82
+
83
+ ENCODING_FLAG = '#.*coding[:=]\s*(\S+)[ \t]*'
84
+
85
+ def self.eager_load!
86
+ super
87
+ ActionView::Helpers.eager_load!
88
+ ActionView::Template.eager_load!
89
+ HTML.eager_load!
90
+ end
91
+ end
92
+
93
+ require 'active_support/core_ext/string/output_safety'
94
+
95
+ ActiveSupport.on_load(:i18n) do
96
+ I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
97
+ end
@@ -0,0 +1,205 @@
1
+ require 'active_support/core_ext/module/attr_internal'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+ require 'active_support/ordered_options'
4
+ require 'action_view/log_subscriber'
5
+ require 'action_view/helpers'
6
+ require 'action_view/context'
7
+ require 'action_view/template'
8
+ require 'action_view/lookup_context'
9
+
10
+ module ActionView #:nodoc:
11
+ # = Action View Base
12
+ #
13
+ # Action View templates can be written in several ways. If the template file has a <tt>.erb</tt> extension then it uses a mixture of ERB
14
+ # (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then Jim Weirich's Builder::XmlMarkup library is used.
15
+ #
16
+ # == ERB
17
+ #
18
+ # You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
19
+ # following loop for names:
20
+ #
21
+ # <b>Names of all the people</b>
22
+ # <% @people.each do |person| %>
23
+ # Name: <%= person.name %><br/>
24
+ # <% end %>
25
+ #
26
+ # The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this
27
+ # is not just a usage suggestion. Regular output functions like print or puts won't work with ERB templates. So this would be wrong:
28
+ #
29
+ # <%# WRONG %>
30
+ # Hi, Mr. <% puts "Frodo" %>
31
+ #
32
+ # If you absolutely must write from within a function use +concat+.
33
+ #
34
+ # <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
35
+ #
36
+ # === Using sub templates
37
+ #
38
+ # Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
39
+ # classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
40
+ #
41
+ # <%= render "shared/header" %>
42
+ # Something really specific and terrific
43
+ # <%= render "shared/footer" %>
44
+ #
45
+ # As you see, we use the output embeddings for the render methods. The render call itself will just return a string holding the
46
+ # result of the rendering. The output embedding writes it to the current template.
47
+ #
48
+ # But you don't have to restrict yourself to static includes. Templates can share variables amongst themselves by using instance
49
+ # variables defined using the regular embedding tags. Like this:
50
+ #
51
+ # <% @page_title = "A Wonderful Hello" %>
52
+ # <%= render "shared/header" %>
53
+ #
54
+ # Now the header can pick up on the <tt>@page_title</tt> variable and use it for outputting a title tag:
55
+ #
56
+ # <title><%= @page_title %></title>
57
+ #
58
+ # === Passing local variables to sub templates
59
+ #
60
+ # You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
61
+ #
62
+ # <%= render "shared/header", { headline: "Welcome", person: person } %>
63
+ #
64
+ # These can now be accessed in <tt>shared/header</tt> with:
65
+ #
66
+ # Headline: <%= headline %>
67
+ # First name: <%= person.first_name %>
68
+ #
69
+ # If you need to find out whether a certain local variable has been assigned a value in a particular render call,
70
+ # you need to use the following pattern:
71
+ #
72
+ # <% if local_assigns.has_key? :headline %>
73
+ # Headline: <%= headline %>
74
+ # <% end %>
75
+ #
76
+ # Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
77
+ #
78
+ # === Template caching
79
+ #
80
+ # By default, Rails will compile each template to a method in order to render it. When you alter a template,
81
+ # Rails will check the file's modification time and recompile it in development mode.
82
+ #
83
+ # == Builder
84
+ #
85
+ # Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object
86
+ # named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
87
+ #
88
+ # Here are some basic examples:
89
+ #
90
+ # xml.em("emphasized") # => <em>emphasized</em>
91
+ # xml.em { xml.b("emph & bold") } # => <em><b>emph &amp; bold</b></em>
92
+ # xml.a("A Link", "href" => "http://onestepback.org") # => <a href="http://onestepback.org">A Link</a>
93
+ # xml.target("name" => "compile", "option" => "fast") # => <target option="fast" name="compile"\>
94
+ # # NOTE: order of attributes is not specified.
95
+ #
96
+ # Any method with a block will be treated as an XML markup tag with nested markup in the block. For example, the following:
97
+ #
98
+ # xml.div do
99
+ # xml.h1(@person.name)
100
+ # xml.p(@person.bio)
101
+ # end
102
+ #
103
+ # would produce something like:
104
+ #
105
+ # <div>
106
+ # <h1>David Heinemeier Hansson</h1>
107
+ # <p>A product of Danish Design during the Winter of '79...</p>
108
+ # </div>
109
+ #
110
+ # A full-length RSS example actually used on Basecamp:
111
+ #
112
+ # xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
113
+ # xml.channel do
114
+ # xml.title(@feed_title)
115
+ # xml.link(@url)
116
+ # xml.description "Basecamp: Recent items"
117
+ # xml.language "en-us"
118
+ # xml.ttl "40"
119
+ #
120
+ # @recent_items.each do |item|
121
+ # xml.item do
122
+ # xml.title(item_title(item))
123
+ # xml.description(item_description(item)) if item_description(item)
124
+ # xml.pubDate(item_pubDate(item))
125
+ # xml.guid(@person.firm.account.url + @recent_items.url(item))
126
+ # xml.link(@person.firm.account.url + @recent_items.url(item))
127
+ #
128
+ # xml.tag!("dc:creator", item.author_name) if item_has_creator?(item)
129
+ # end
130
+ # end
131
+ # end
132
+ # end
133
+ #
134
+ # More builder documentation can be found at http://builder.rubyforge.org.
135
+ class Base
136
+ include Helpers, ::ERB::Util, Context
137
+
138
+ # Specify the proc used to decorate input tags that refer to attributes with errors.
139
+ cattr_accessor :field_error_proc
140
+ @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
141
+
142
+ # How to complete the streaming when an exception occurs.
143
+ # This is our best guess: first try to close the attribute, then the tag.
144
+ cattr_accessor :streaming_completion_on_exception
145
+ @@streaming_completion_on_exception = %("><script>window.location = "/500.html"</script></html>)
146
+
147
+ # Specify whether rendering within namespaced controllers should prefix
148
+ # the partial paths for ActiveModel objects with the namespace.
149
+ # (e.g., an Admin::PostsController would render @post using /admin/posts/_post.erb)
150
+ cattr_accessor :prefix_partial_path_with_controller_namespace
151
+ @@prefix_partial_path_with_controller_namespace = true
152
+
153
+ # Specify default_formats that can be rendered.
154
+ cattr_accessor :default_formats
155
+
156
+ class_attribute :_routes
157
+ class_attribute :logger
158
+
159
+ class << self
160
+ delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
161
+
162
+ def cache_template_loading
163
+ ActionView::Resolver.caching?
164
+ end
165
+
166
+ def cache_template_loading=(value)
167
+ ActionView::Resolver.caching = value
168
+ end
169
+
170
+ def xss_safe? #:nodoc:
171
+ true
172
+ end
173
+ end
174
+
175
+ attr_accessor :view_renderer
176
+ attr_internal :config, :assigns
177
+
178
+ delegate :lookup_context, :to => :view_renderer
179
+ delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context
180
+
181
+ def assign(new_assigns) # :nodoc:
182
+ @_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) }
183
+ end
184
+
185
+ def initialize(context = nil, assigns = {}, controller = nil, formats = nil) #:nodoc:
186
+ @_config = ActiveSupport::InheritableOptions.new
187
+
188
+ if context.is_a?(ActionView::Renderer)
189
+ @view_renderer = context
190
+ else
191
+ lookup_context = context.is_a?(ActionView::LookupContext) ?
192
+ context : ActionView::LookupContext.new(context)
193
+ lookup_context.formats = formats if formats
194
+ lookup_context.prefixes = controller._prefixes if controller
195
+ @view_renderer = ActionView::Renderer.new(lookup_context)
196
+ end
197
+
198
+ assign(assigns)
199
+ assign_controller(controller)
200
+ _prepare_context
201
+ end
202
+
203
+ ActiveSupport.run_load_hooks(:action_view, self)
204
+ end
205
+ end