page_title_helper 0.7.0 → 0.7.1

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/README.md CHANGED
@@ -20,6 +20,19 @@ When `contacs/index.html.erb` is rendered, the key `:en, :contacts, :index, :tit
20
20
  is looked up and printed, together with the applications basename, like: `My cool app - Contacts`.
21
21
  The format etc. is of course configurable, just head down to the options.
22
22
 
23
+ ## Installation
24
+
25
+ As gem (from gemcutter.org, since version 0.7.0):
26
+
27
+ sudo gem install page_title_helper [-s http://gemcutter.org]
28
+
29
+ # then add the following line to config/environment.rb
30
+ config.gem 'page_title_helper', :source => 'http://gemcutter.org'
31
+
32
+ Or old school as Rails plugin:
33
+
34
+ ./script/plugin install git://github.com/lwe/page_title_helper.git
35
+
23
36
  ## Customize titles
24
37
 
25
38
  Need a custom title, or need to fill in some placeholders? Just provide a block, in e.g.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 0
4
+ :patch: 1
@@ -11,7 +11,7 @@
11
11
  module PageTitleHelper
12
12
  module Interpolations
13
13
  # Represents the environment which is passed into each interpolation call.
14
- class Env < Struct.new(:options, :view, :controller, :title); end
14
+ class TitleEnv < ::Struct.new(:options, :view, :controller, :title); end
15
15
 
16
16
  extend self
17
17
 
@@ -58,8 +58,8 @@ module PageTitleHelper
58
58
 
59
59
  def page_title(options = nil, &block)
60
60
  if block_given? # define title
61
- content_for(:page_title) { yield }
62
- return (title = read_page_title_content_block).is_a?(Array) ? title.first : title
61
+ @_page_title = yield
62
+ return @_page_title.is_a?(Array) ? @_page_title.first : @_page_title
63
63
  end
64
64
 
65
65
  options = PageTitleHelper.options.merge(options || {}).symbolize_keys!
@@ -67,10 +67,10 @@ module PageTitleHelper
67
67
  options.assert_valid_keys(:app, :suffix, :default, :format)
68
68
 
69
69
  # construct basic env to pass around
70
- env = Interpolations::Env.new(options, self, self.controller)
70
+ env = Interpolations::TitleEnv.new(options, self, self.controller)
71
71
 
72
72
  # read page title and split into 'real' title and customized format
73
- env.title = read_page_title_content_block || I18n.translate(i18n_template_key(options[:suffix]), :default => options[:default])
73
+ env.title = @_page_title || I18n.translate(i18n_template_key(options[:suffix]), :default => options[:default])
74
74
  env.title, options[:format] = *(env.title << options[:format]) if env.title.is_a?(Array)
75
75
 
76
76
  # handle format aliases
@@ -81,18 +81,7 @@ module PageTitleHelper
81
81
  Interpolations.interpolate format, env
82
82
  end
83
83
 
84
- protected
85
-
86
- # Access <tt>@content_for_page_title</tt> variable, though this is a tad
87
- # hacky, because... what if they (the rails guys) change the behaviour of
88
- # <tt>content_for</tt>? Well, in Rails 2.3.x it works so far.
89
- #
90
- # But to simplify compatibility with later versions, this method kinda abstracts
91
- # away access to the content within a <tt>content_for</tt> block.
92
- def read_page_title_content_block
93
- instance_variable_get(:'@content_for_page_title')
94
- end
95
-
84
+ protected
96
85
  # Access +ActionView+s internal <tt>@_first_render</tt> variable, to access
97
86
  # template first rendered, this is to help create the DRY-I18n-titles magic,
98
87
  # and also kind of a hack, because this really seems to be some sort if
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{page_title_helper}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lukas Westermann"]
12
- s.date = %q{2009-09-29}
12
+ s.date = %q{2009-11-11}
13
13
  s.email = %q{lukas.westermann@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -53,3 +53,4 @@ Gem::Specification.new do |s|
53
53
  else
54
54
  end
55
55
  end
56
+
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.0
4
+ version: 0.7.1
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-09-29 00:00:00 +02:00
12
+ date: 2009-11-11 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15