blockpile 0.3.0 → 0.4.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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
data/blockpile.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{blockpile}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Flint"]
12
- s.date = %q{2010-08-16}
12
+ s.date = %q{2010-08-20}
13
13
  s.description = %q{This module attempts to create structured view helpers. Essentially, a blockpile consists of a ruby class file, and a template. This allows for isolated blocks of view logic, that can maintain a clean separation of markup language from ruby code. Blocks can be inherited from to DRY up view logic.}
14
14
  s.email = %q{tylerflint@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  "blockpile.gemspec",
25
25
  "lib/blockpile.rb",
26
26
  "lib/blockpile/base.rb",
27
- "lib/blockpile/paths.rb",
28
27
  "lib/blockpile/setup.rb",
29
28
  "lib/generators/blockpile/USAGE",
30
29
  "lib/generators/blockpile/blockpile_generator.rb",
@@ -1,17 +1,22 @@
1
1
  class Blockpile::Base
2
2
 
3
- def initialize(helper, session, params, template, *args)
3
+ def initialize(helper, session, params, template, *args, &block)
4
4
  @helper = helper
5
5
  @session = session
6
6
  @params = params
7
7
  @template = template
8
8
  build *args
9
+ @content = capture(self, &block) if block_given?
9
10
  end
10
11
 
11
12
  def to_html
12
13
  render_template
13
14
  end
14
15
 
16
+ def get_content
17
+ @content
18
+ end
19
+
15
20
  def build
16
21
  # override this method to build your block
17
22
  end
@@ -20,13 +25,14 @@ protected
20
25
 
21
26
  # Assumes /views/helper/ as base
22
27
  def render_template
23
- ERB.new( File.read( get_template ) ).result binding
28
+ render( :partial => @template, :locals => {:pile => self, :p => self})
24
29
  end
25
30
 
26
31
  def get_template
27
32
  get_paths.each do |path|
28
33
  if File::exists?( path + "/" + @template + ".html.erb")
29
- return path + "/" + @template + ".html.erb"
34
+ return path + "/" + @template
35
+ puts path + "/" + @template
30
36
  end
31
37
  end
32
38
  raise "Unable to find template for this blockpile"
@@ -1,14 +1,13 @@
1
1
  module Blockpile
2
2
  module Setup
3
3
  def self.add_load_path(path)
4
- Dir.glob(path + "/**/*.rb") do |file|
4
+ Dir.glob(path + "/**/*_pile.rb") do |file|
5
5
  ActiveSupport::Dependencies.autoload_paths << File.dirname(file)
6
- file_name = file.split(/\//).pop.gsub(/.rb/, '')
6
+ file_name = file.split(/\//).pop.gsub(/\.rb/, '')
7
7
  class_name = file_name.classify
8
8
  ActionView::Base.class_eval %{
9
- def #{file_name}(*args, &block)
10
- blockpile = #{class_name}.new(self, session, params, '#{file_name}', *args)
11
- yield blockpile if block_given?
9
+ def #{file_name.gsub(/\_pile/, '')}(*args, &block)
10
+ blockpile = #{class_name}.new(self, session, params, '#{file_name}', *args, &block)
12
11
  raw blockpile.to_html
13
12
  end
14
13
  }
data/lib/blockpile.rb CHANGED
@@ -1,15 +1,13 @@
1
1
  require 'rails'
2
2
  require 'blockpile/setup'
3
3
  require 'blockpile/base'
4
- require 'blockpile/paths'
5
4
 
6
5
  module Blockpile
7
6
  class Railtie < Rails::Railtie
8
7
  initializer "blockpile.setup default directories" do
9
8
  Blockpile.setup do |config|
10
- config.add_load_path Rails.root.to_s + '/app/helpers/blockpiles'
9
+ config.add_load_path Rails.root.to_s + '/app/helpers'
11
10
  end
12
- Blockpile::Paths.add_template_path Rails.root.to_s + '/app/views/blockpiles/'
13
11
  end
14
12
  end
15
13
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
7
+ - 4
8
8
  - 0
9
- version: 0.3.0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tyler Flint
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-16 00:00:00 -06:00
17
+ date: 2010-08-20 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -35,7 +35,6 @@ files:
35
35
  - blockpile.gemspec
36
36
  - lib/blockpile.rb
37
37
  - lib/blockpile/base.rb
38
- - lib/blockpile/paths.rb
39
38
  - lib/blockpile/setup.rb
40
39
  - lib/generators/blockpile/USAGE
41
40
  - lib/generators/blockpile/blockpile_generator.rb
@@ -1,15 +0,0 @@
1
- module Blockpile
2
- module Paths
3
-
4
- @@paths = []
5
-
6
- def self.add_template_path(path)
7
- @@paths << path
8
- end
9
-
10
- def self.get_paths
11
- @@paths
12
- end
13
-
14
- end
15
- end