page_title_helper 0.7.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  doc/
2
2
  pkg/
3
3
  .yardoc
4
+ *.gemspec
data/README.md CHANGED
@@ -22,34 +22,33 @@ The format etc. is of course configurable, just head down to the options.
22
22
 
23
23
  ## Installation
24
24
 
25
- As gem (from gemcutter.org, since version 0.7.0):
25
+ As gem (from gemcutter.org, as of version 0.7.0):
26
26
 
27
27
  sudo gem install page_title_helper [-s http://gemcutter.org]
28
28
 
29
29
  # then add the following line to config/environment.rb
30
30
  config.gem 'page_title_helper', :source => 'http://gemcutter.org'
31
31
 
32
- Or old school as Rails plugin:
32
+ or as plain old Rails plugin:
33
33
 
34
34
  ./script/plugin install git://github.com/lwe/page_title_helper.git
35
35
 
36
36
  ## Customize titles
37
37
 
38
- Need a custom title, or need to fill in some placeholders? Just provide a block, in e.g.
38
+ Need a custom title, or need to fill in some placeholders? Just use the _bang_ method (`page_title!`), in e.g.
39
39
  `contacts/show.html.erb` the requirement is to display the contacts name in the
40
40
  `<title>-tag`as well as in the heading?
41
41
 
42
- <h1><%=h page_title { @contact.name } %></h1>
42
+ <h1><%=h page_title!(@contact.name) %></h1>
43
43
 
44
44
  A call to `page_title` will now return the contacts name, neat :) if for example the
45
- `<h1>` does not match the +title+, then
46
- well, just do something like:
45
+ `<h1>` does not match the `<title>`, then well, just do something like:
47
46
 
48
- <% page_title { @contact.name + " (" + @contact.company.name + ")" } %>
47
+ <% page_title!(@contact.name + " (" + @contact.company.name + ")") %>
49
48
  <h1><%=h @contact.name %></h1>
50
49
 
51
- Guess, that's it. Of course it's also possible to use `translate` within the `page_title` block, so
52
- to translate customzied titles, like:
50
+ Guess, that's it. Of course it's also possible to use `translate` with `page_title!`, to
51
+ translate customzied titles, like:
53
52
 
54
53
  # in config/locales/en.yml:
55
54
  en:
@@ -58,10 +57,7 @@ to translate customzied titles, like:
58
57
  title: "Welcome back, {{name}}"
59
58
 
60
59
  # in app/views/dashboard/index.html.erb:
61
- <h1><%=h page_title { t '.title', :name => @user.first_name } %></h1>
62
-
63
- Btw - a helpful rule-of-thumb: if `page_title` is used with a block a title is **defined**,
64
- if it's used without the current title is rendered.
60
+ <h1><%=h page_title!(t('.title', :name => @user.first_name)) %></h1>
65
61
 
66
62
  ## More fun with <tt>:format</tt>
67
63
 
@@ -82,16 +78,16 @@ controller:
82
78
 
83
79
  To access just the title, without any magic app stuff interpolated or appended, use:
84
80
 
85
- page_title { "untitled" }
81
+ page_title! "untitled"
86
82
  page_title :format => false # => "untitled"
87
83
 
88
84
  Need a custom format for a single title? Just return an array:
89
85
 
90
86
  # in the view:
91
- <h1><%= h(page_title { [@contact.name, ":title from :company - :app"] } %></h1> # => <h1>Franz Meyer</h1>
87
+ <h1><%=h page_title!(@contact.name, ":title from :company - :app") %></h1> # => <h1>Franz Meyer</h1>
92
88
 
93
89
  # in the <head>
94
- <title><%= h(page_title) %></title> # => this time it will use custom title like "Franz Meyer from ABC Corp. - MyCoolApp"
90
+ <title><%=h(page_title) %></title> # => this time it will use custom title like "Franz Meyer from ABC Corp. - MyCoolApp"
95
91
 
96
92
  To streamline that feature a bit and simplify reuse of often used formats, it's now possible to define format aliases like:
97
93
 
@@ -100,7 +96,7 @@ To streamline that feature a bit and simplify reuse of often used formats, it's
100
96
  PageTitleHelper.formats[:promo] = ":app - :title" # show app first for promo pages :)
101
97
 
102
98
  # then in the view to display a contact...
103
- page_title { [@contact.name, :with_company] }
99
+ page_title! @contact.name, :with_company
104
100
 
105
101
  # ...or for the promo page via config/locales/en.yml (!)
106
102
  en:
@@ -109,8 +105,7 @@ To streamline that feature a bit and simplify reuse of often used formats, it's
109
105
  title:
110
106
  - "Features comparison"
111
107
  - !ruby/sym promo
112
-
113
-
108
+
114
109
  Pretty, cool, aint it? The special `:format => :app` works also with the `formats` hash. Then there is also a
115
110
  `:default` format, which should be used to override the default format.
116
111
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
- :minor: 7
4
- :patch: 1
2
+ :major: 1
3
+ :minor: 0
4
+ :patch: 0
@@ -56,11 +56,14 @@ module PageTitleHelper
56
56
  }
57
57
  end
58
58
 
59
+ # Specify page title
60
+ def page_title!(*args)
61
+ @_page_title = args.size > 1 ? args : args.first
62
+ @_page_title.is_a?(Array) ? @_page_title.first : @_page_title
63
+ end
64
+
59
65
  def page_title(options = nil, &block)
60
- if block_given? # define title
61
- @_page_title = yield
62
- return @_page_title.is_a?(Array) ? @_page_title.first : @_page_title
63
- end
66
+ return page_title!(yield) if block_given? # define title
64
67
 
65
68
  options = PageTitleHelper.options.merge(options || {}).symbolize_keys!
66
69
  options[:format] ||= :title # handles :format => false
@@ -81,25 +84,12 @@ module PageTitleHelper
81
84
  Interpolations.interpolate format, env
82
85
  end
83
86
 
84
- protected
85
- # Access +ActionView+s internal <tt>@_first_render</tt> variable, to access
86
- # template first rendered, this is to help create the DRY-I18n-titles magic,
87
- # and also kind of a hack, because this really seems to be some sort if
88
- # internal variable, that's why it's "abstracted" away as well.
89
- #
90
- # Also ensure that the extensions (like <tt>.html.erb</tt> or
91
- # <tt>.html.haml</tt>) have been stripped of and translated in the sense
92
- # of converting <tt>/</tt> to <tt>.</tt>.
93
- def first_render_path_translated
94
- @_first_render.template_path.gsub(/\.[^\/]*\Z/, '').tr('/', '.')
95
- end
96
-
97
- def i18n_template_key(suffix = nil)
98
- first_render_path_translated + (suffix.present? ? ".#{suffix}" : "")
87
+ protected
88
+
89
+ # Find current title key based on currently rendering template, same
90
+ # code as in {ActionView::Helpers::TranslationHelpers} to get that <tt>'.relative_key'</tt>
91
+ # magic working.
92
+ def i18n_template_key(suffix = :title)
93
+ template.path_without_format_and_extension.gsub(%r{/_?}, '.') + ".#{suffix}"
99
94
  end
100
- end
101
-
102
- # tie stuff together
103
- if Object.const_defined?('ActionView')
104
- ActionView::Base.send(:include, PageTitleHelper)
105
95
  end
data/rails/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'page_title_helper'
2
+
3
+ # include helper methods in ActionView
4
+ ActionView::Base.send(:include, PageTitleHelper) if defined?(ActionView)
@@ -1,11 +1,11 @@
1
1
  require 'test_helper'
2
2
  require 'page_title_helper'
3
- require 'mocks'
4
3
 
5
4
  class MultipleFormatsTest < ActiveSupport::TestCase
6
5
  context "#page_title supporting multiple formats through arrays" do
7
6
  setup do
8
- @view = MockView.new
7
+ @view = ActionView::Base.new
8
+ @view.template = ActionView::Template.new "contacts/list.html.erb"
9
9
  end
10
10
 
11
11
  should "accept an array passed in the page_title block and use the second argument as format" do
@@ -21,7 +21,8 @@ class MultipleFormatsTest < ActiveSupport::TestCase
21
21
  context "#page_title with format aliases" do
22
22
  setup do
23
23
  PageTitleHelper.formats[:myformat] = ":title <-> :app"
24
- @view = MockView.new
24
+ @view = ActionView::Base.new
25
+ @view.template = ActionView::Template.new "contacts/list.html.erb"
25
26
  end
26
27
 
27
28
  should "have a default alias named :app" do
@@ -56,15 +57,16 @@ class MultipleFormatsTest < ActiveSupport::TestCase
56
57
  I18n.load_path = [File.join(File.dirname(__FILE__), "en_wohaapp.yml")]
57
58
  I18n.reload!
58
59
  PageTitleHelper.formats[:promo] = ":app > :title"
60
+ @view = ActionView::Base.new
59
61
  end
60
62
 
61
63
  should "allow to overide format through YAML" do
62
- @view = MockView.new('pages/features.html.haml')
64
+ mock(@view).template { ActionView::Template.new 'pages/features.html.haml' }
63
65
  assert_equal 'Wohaapp > Feature comparison', @view.page_title
64
66
  end
65
67
 
66
68
  should "handle raw string formats from YAML as well" do
67
- @view = MockView.new('pages/signup.html.haml')
69
+ mock(@view).template { ActionView::Template.new 'pages/signup.html.haml' }
68
70
  assert_equal 'Sign up for Wohaapp now!', @view.page_title
69
71
  end
70
72
  end
@@ -1,109 +1,117 @@
1
1
  require 'test_helper'
2
2
  require 'page_title_helper'
3
3
  require 'ostruct'
4
- require 'mocks'
5
4
 
5
+ class PageTitleHelperTest < ActiveSupport::TestCase
6
+ context "PageTitleHelper" do
7
+ setup do
8
+ I18n.load_path = [File.join(File.dirname(__FILE__), 'en.yml')]
9
+ I18n.reload!
10
+
11
+ @view = ActionView::Base.new
12
+ @view.template = ActionView::Template.new "contacts/list.html.erb"
13
+ end
14
+
15
+ context "::Interpolations" do
16
+ should "interpolate :app and :title" do
17
+ assert_equal 'Page title helper', PageTitleHelper::Interpolations.app(OpenStruct.new(:options => {}))
18
+ assert_equal 'Appname', PageTitleHelper::Interpolations.app(OpenStruct.new(:options => { :app => 'Appname' }))
19
+ assert_equal 'untitled', PageTitleHelper::Interpolations.title(OpenStruct.new({:title => 'untitled'}))
20
+ end
6
21
 
7
- class PageTitleHelperTest < ActiveSupport::TestCase
8
- def setup
9
- I18n.load_path = [File.join(File.dirname(__FILE__), 'en.yml')]
10
- I18n.reload!
11
- end
12
-
13
- test "interpolations" do
14
- assert_equal 'Page title helper', PageTitleHelper::Interpolations.app(OpenStruct.new(:options => {}))
15
- assert_equal 'Appname', PageTitleHelper::Interpolations.app(OpenStruct.new(:options => { :app => 'Appname' }))
16
- assert_equal 'untitled', PageTitleHelper::Interpolations.title(OpenStruct.new({:title => 'untitled'}))
17
- end
18
-
19
- test "adding custom interpolation" do
20
- # extend Interpolations
21
- PageTitleHelper.interpolates(:app_reverse) { |env| app(env).reverse.downcase }
22
+ should "allow adding custom interpolations" do
23
+ # extend Interpolations
24
+ PageTitleHelper.interpolates(:app_reverse) { |env| app(env).reverse.downcase }
22
25
 
23
- assert_equal "anna", PageTitleHelper::Interpolations.app_reverse(OpenStruct.new(:options => { :app => 'Anna' }))
24
- assert_equal "ppa", PageTitleHelper::Interpolations.interpolate(':app_reverse', OpenStruct.new(:options => { :app => 'app' }))
25
- end
26
-
27
- test "that interpolations which are equaly named do match in correct order (longest first)" do
28
- PageTitleHelper.interpolates(:foobar) { "foobar" }
29
- PageTitleHelper.interpolates(:foobar_test) { "foobar_test" }
30
- PageTitleHelper.interpolates(:title_foobar) { "title_foobar" }
26
+ assert_equal "anna", PageTitleHelper::Interpolations.app_reverse(OpenStruct.new(:options => { :app => 'Anna' }))
27
+ assert_equal "ppa", PageTitleHelper::Interpolations.interpolate(':app_reverse', OpenStruct.new(:options => { :app => 'app' }))
28
+ end
29
+
30
+ should "interpolate in correct order, i.e. longest first" do
31
+ PageTitleHelper.interpolates(:foobar) { "foobar" }
32
+ PageTitleHelper.interpolates(:foobar_test) { "foobar_test" }
33
+ PageTitleHelper.interpolates(:title_foobar) { "title_foobar" }
31
34
 
32
- assert_equal "title_foobar / foobar_test / foobar / foobar_x", PageTitleHelper::Interpolations.interpolate(":title_foobar / :foobar_test / :foobar / :foobar_x", nil)
33
- end
34
-
35
-
36
- test "setting title to 'foo' returns 'foo'" do
37
- view = MockView.new
38
- view.page_title { "foo" }
39
- assert_equal 'foo - Page title helper', view.page_title
40
- end
41
-
42
- test "reading defaults from I18n" do
43
- view = MockView.new 'contacts/list.html.erb'
44
- assert_equal 'contacts.list.title - Page title helper', view.page_title
45
- end
46
-
47
- test "printing app name only if :format => :app" do
48
- view = MockView.new
49
- assert_equal 'Page title helper', view.page_title(:format => :app)
50
- end
51
-
52
- test "printing custom app name if :app defined and :format => :app" do
53
- view = MockView.new
54
- assert_equal "Some app", view.page_title(:app => 'Some app', :format => :app)
55
- end
56
-
57
- test "custom formatting options" do
58
- view = MockView.new
59
- view.page_title { "test" }
35
+ assert_equal "title_foobar / foobar_test / foobar / foobar_x", PageTitleHelper::Interpolations.interpolate(":title_foobar / :foobar_test / :foobar / :foobar_x", nil)
36
+ end
37
+ end
38
+
39
+ context "#page_title (define w/ block)" do
40
+ should "return title from block and render with app name" do
41
+ assert_equal 'foo', @view.page_title { "foo" }
42
+ assert_equal 'foo - Page title helper', @view.page_title
43
+ end
44
+
45
+ should "set custom title using a translation with a placeholder" do
46
+ assert_equal "Displaying Bella", @view.page_title { I18n.t(:placeholder, :name => 'Bella') }
47
+ assert_equal "Displaying Bella - Page title helper", @view.page_title
48
+ end
49
+ end
60
50
 
61
- assert_equal "Some app :: test", view.page_title(:app => "Some app", :format => ':app :: :title')
62
- assert_equal "Some app / test", view.page_title(:format => 'Some app / :title')
63
- end
64
-
65
- test "return value of block to be used as heading" do
66
- view = MockView.new
67
- assert_equal "untitled", view.page_title { "untitled" }
68
- end
69
-
70
- test "calling :format => false returns just current title, without any interpolations etc." do
71
- view = MockView.new
72
- view.page_title { "untitled" }
73
- assert_equal "untitled", view.page_title(:format => false)
51
+ context "#page_title! (define)" do
52
+ should "set page title" do
53
+ assert_equal 'test', @view.page_title!('test')
54
+ assert_equal 'test - Page title helper', @view.page_title
55
+ end
56
+
57
+ should "set page title and interpret second argument as custom format" do
58
+ PageTitleHelper.formats[:bang] = ":title !! :app"
59
+ assert_equal 'test', @view.page_title!('test', :bang)
60
+ assert_equal 'test !! Page title helper', @view.page_title
61
+ end
62
+ end
74
63
 
75
- i18n_view = MockView.new 'contacts/list.html.erb'
76
- assert_equal "contacts.list.title", i18n_view.page_title(:format => false)
77
- end
78
-
79
- test "custom title using a translation with a placeholder" do
80
- view = MockView.new
81
- view.page_title { I18n.t :placeholder, :name => 'Bella' }
82
- assert_equal "Displaying Bella - Page title helper", view.page_title
83
- end
84
-
85
- test "render translated :'app.tagline' if no title is available" do
86
- view = MockView.new 'view/does/not_exist.html.erb'
87
- assert_equal "Default - Page title helper", view.page_title
88
- end
89
-
90
- test "render custom 'default' string, if title is not available" do
91
- view = MockView.new 'view/does/not_exist.html.erb'
92
- assert_equal 'Some default - Page title helper', view.page_title(:default => 'Some default')
93
- end
94
-
95
- test "render custom default translation, if title is not available" do
96
- view = MockView.new 'view/does/not_exist.html.erb'
97
- assert_equal 'Other default - Page title helper', view.page_title(:default => :'app.other_tagline')
98
- end
99
-
100
- test "render auto-title using custom suffix 'page_title'" do
101
- view = MockView.new 'contacts/list.html.erb'
102
- assert_equal 'custom contacts title - Page title helper', view.page_title(:suffix => :page_title)
64
+ context "#page_title (rendering)" do
65
+ should "read default title from I18n, based on template" do
66
+ assert_equal 'contacts.list.title - Page title helper', @view.page_title
67
+ end
68
+
69
+ should "only print app name if :format => :app" do
70
+ assert_equal 'Page title helper', @view.page_title(:format => :app)
71
+ end
72
+
73
+ should "print custom app name if :app defined and :format => :app" do
74
+ assert_equal "Some app", @view.page_title(:app => 'Some app', :format => :app)
75
+ end
76
+
77
+ should "use custom format, if :format option is defined" do
78
+ assert_equal 'test', @view.page_title { "test" }
79
+ assert_equal "Some app :: test", @view.page_title(:app => "Some app", :format => ':app :: :title')
80
+ assert_equal "Some app / test", @view.page_title(:format => 'Some app / :title')
81
+ end
82
+
83
+ should "return just title if :format => false is passed" do
84
+ assert_equal 'untitled', @view.page_title { "untitled" }
85
+ assert_equal "untitled", @view.page_title(:format => false)
86
+ end
87
+
88
+ should "return title if :format => false and when using the DRY-I18n titles" do
89
+ assert_equal "contacts.list.title", @view.page_title(:format => false)
90
+ end
91
+
92
+ should "render translated :'app.tagline' if no title is available" do
93
+ mock(@view).template { ActionView::Template.new('view/does/not_exist.html.erb') }
94
+ assert_equal "Default - Page title helper", @view.page_title
95
+ end
96
+
97
+ should "render custom 'default' string, if title is not available" do
98
+ mock(@view).template { ActionView::Template.new('view/does/not_exist.html.erb') }
99
+ assert_equal 'Some default - Page title helper', @view.page_title(:default => 'Some default')
100
+ end
101
+
102
+ should "render custom default translation, if title is not available" do
103
+ mock(@view).template { ActionView::Template.new('view/does/not_exist.html.erb') }
104
+ assert_equal 'Other default - Page title helper', @view.page_title(:default => :'app.other_tagline')
105
+ end
106
+
107
+ should "render auto-title using custom suffix 'page_title'" do
108
+ assert_equal 'custom contacts title - Page title helper', @view.page_title(:suffix => :page_title)
109
+ end
110
+
111
+ should "work with other template engines, like HAML" do
112
+ mock(@view).template { ActionView::Template.new('contacts/myhaml.html.haml') }
113
+ assert_equal 'this is haml! - Page title helper', @view.page_title
114
+ end
115
+ end
103
116
  end
104
-
105
- test "ensure that it works with other template engines, like .html.haml" do
106
- view = MockView.new('contacts/myhaml.html.haml')
107
- assert_equal 'this is haml! - Page title helper', view.page_title
108
- end
109
117
  end
data/test/test_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'active_support'
3
3
  require 'action_view'
4
+ require File.join(File.dirname(__FILE__), '..', 'rails', 'init')
4
5
 
5
- unless Object.const_defined?('IRB')
6
+ unless defined?(IRB)
6
7
  require 'active_support/test_case'
7
8
  require 'shoulda'
8
9
  require 'rr'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_title_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Westermann
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-11 00:00:00 +01:00
12
+ date: 2009-11-20 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,12 +28,10 @@ files:
28
28
  - README.md
29
29
  - Rakefile
30
30
  - VERSION.yml
31
- - init.rb
32
31
  - lib/page_title_helper.rb
33
- - page_title_helper.gemspec
32
+ - rails/init.rb
34
33
  - test/en.yml
35
34
  - test/en_wohaapp.yml
36
- - test/mocks.rb
37
35
  - test/multiple_formats_test.rb
38
36
  - test/page_title_helper_test.rb
39
37
  - test/test_helper.rb
@@ -66,7 +64,6 @@ signing_key:
66
64
  specification_version: 3
67
65
  summary: Simple, internationalized and DRY page titles and headings for rails.
68
66
  test_files:
69
- - test/mocks.rb
70
67
  - test/multiple_formats_test.rb
71
68
  - test/page_title_helper_test.rb
72
69
  - test/test_helper.rb
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'lib', 'page_title_helper')
@@ -1,56 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{page_title_helper}
8
- s.version = "0.7.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Lukas Westermann"]
12
- s.date = %q{2009-11-11}
13
- s.email = %q{lukas.westermann@gmail.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.md"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "LICENSE",
21
- "README.md",
22
- "Rakefile",
23
- "VERSION.yml",
24
- "init.rb",
25
- "lib/page_title_helper.rb",
26
- "page_title_helper.gemspec",
27
- "test/en.yml",
28
- "test/en_wohaapp.yml",
29
- "test/mocks.rb",
30
- "test/multiple_formats_test.rb",
31
- "test/page_title_helper_test.rb",
32
- "test/test_helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/lwe/page_title_helper}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.5}
38
- s.summary = %q{Simple, internationalized and DRY page titles and headings for rails.}
39
- s.test_files = [
40
- "test/mocks.rb",
41
- "test/multiple_formats_test.rb",
42
- "test/page_title_helper_test.rb",
43
- "test/test_helper.rb"
44
- ]
45
-
46
- if s.respond_to? :specification_version then
47
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
- s.specification_version = 3
49
-
50
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
- else
52
- end
53
- else
54
- end
55
- end
56
-
data/test/mocks.rb DELETED
@@ -1,20 +0,0 @@
1
- class MockRender
2
- def initialize(template_path = 'contacts/index.html.erb')
3
- @template_path = template_path
4
- end
5
- def template_path; @template_path; end
6
- end
7
-
8
- class MockView
9
- include PageTitleHelper
10
-
11
- def initialize(template_path = 'contacts/index.html.erb')
12
- @_first_render = MockRender.new template_path
13
- end
14
-
15
- def content_for(sym, &block)
16
- instance_variable_set('@content_for_' + sym.to_s, yield)
17
- end
18
-
19
- def controller; nil; end
20
- end