content_for_in_controllers 0.0.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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in content_for_in_controllers.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ content_for_in_controllers (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ content_for_in_controllers!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "content_for_in_controllers/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "content_for_in_controllers"
7
+ s.version = ContentForInControllers::VERSION
8
+ s.authors = ["Clément Alexandre"]
9
+ s.email = ["clmntlxndr@gmail.com"]
10
+ s.homepage = "http://github.com/clmntlxndr/content_for-in-controllers"
11
+ s.summary = %q{Enables use of content_for in controllers}
12
+ s.description = %q{Enables use of content_for in controllers}
13
+
14
+ s.rubyforge_project = "content_for_in_controllers"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,22 @@
1
+ module ContentForInControllers
2
+ def view_context
3
+ super.tap do |view|
4
+ (@_content_for || {}).each do |name,content|
5
+ view.content_for name, content
6
+ end
7
+ end
8
+ end
9
+ def content_for(name, content) # no blocks allowed yet
10
+ @_content_for ||= {}
11
+ if @_content_for[name].respond_to?(:<<)
12
+ @_content_for[name] << content
13
+ else
14
+ @_content_for[name] = content
15
+ end
16
+ end
17
+ def content_for?(name)
18
+ @_content_for[name].present?
19
+ end
20
+ end
21
+
22
+ ActionController::Base.send :include, ContentForInControllers
@@ -0,0 +1,3 @@
1
+ module ContentForInControllers
2
+ VERSION = "0.0.1"
3
+ end
data/readme.md ADDED
@@ -0,0 +1,20 @@
1
+ content_for in controllers
2
+ --------------------------
3
+
4
+ Enables use of content_for in your controllers
5
+
6
+ # in a controller
7
+ before_filter :set_title
8
+
9
+ def set_title
10
+ content_for :page_title, "Hello !"
11
+ end
12
+
13
+ # in a view
14
+ <title><%= yield :page_title %></title>
15
+
16
+ You just can pass strings for now, and I have no precise idea how it would work in an ActionMailer view :)
17
+
18
+ Simply this [gist](https://gist.github.com/985457) by [hiroshi](https://github.com/hiroshi) Gemified
19
+
20
+ Say hello [@clmntlxndr](http://twitter.com/clmntlxndr)
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: content_for_in_controllers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Clément Alexandre
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-13 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Enables use of content_for in controllers
15
+ email:
16
+ - clmntlxndr@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - Rakefile
24
+ - content_for_in_controllers.gemspec
25
+ - lib/content_for_in_controllers.rb
26
+ - lib/content_for_in_controllers/version.rb
27
+ - readme.md
28
+ homepage: http://github.com/clmntlxndr/content_for-in-controllers
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project: content_for_in_controllers
48
+ rubygems_version: 1.8.6
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Enables use of content_for in controllers
52
+ test_files: []