capcode-render-erb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 glejeune
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.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = capcode-render-erb
2
+
3
+ Capcode plugin to render via Erb
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "capcode-render-erb"
8
+ gem.summary = %Q{Capcode plugin to render via Erb}
9
+ gem.description = gem.summary
10
+ gem.email = "gregoire.lejeune@free.fr"
11
+ gem.homepage = "http://github.com/glejeune/Capcode.more/tree/master/%s" % gem.name
12
+ gem.authors = ["Gregoire Lejeune"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
17
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,45 @@
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{capcode-render-erb}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gregoire Lejeune"]
12
+ s.date = %q{2010-01-07}
13
+ s.description = %q{Capcode plugin to render via Erb}
14
+ s.email = %q{gregoire.lejeune@free.fr}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "LICENSE",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "capcode-render-erb.gemspec",
24
+ "examples/erb/cf.rhtml",
25
+ "examples/erb/cf_layout.rhtml",
26
+ "examples/render-erb.rb",
27
+ "lib/capcode/render/erb.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/glejeune/Capcode.more/tree/master/capcode-render-erb}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{Capcode plugin to render via Erb}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ else
41
+ end
42
+ else
43
+ end
44
+ end
45
+
@@ -0,0 +1,8 @@
1
+ <% content_for( :header ) do %>
2
+ <title>title This is the title!</title>
3
+ <% end %>
4
+
5
+ <% content_for( :content ) do %>
6
+ <p>this is the content!</p>
7
+ <p>Time : <%= @time %>
8
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <%= yield :header %>
4
+ </head>
5
+ <body>
6
+ <%= yield :content %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'capcode'
3
+ require 'rack/bug'
4
+ $:.unshift( "../lib" )
5
+ require 'capcode/render/erb'
6
+
7
+ module Capcode
8
+ set :erb, "erb"
9
+ use Rack::Bug
10
+
11
+ class Index < Route '/'
12
+ def get
13
+ @time = Time.now
14
+ render :erb => :cf, :layout => :cf_layout
15
+ end
16
+ end
17
+ end
18
+
19
+ Capcode.run( )
@@ -0,0 +1,59 @@
1
+ require 'erb'
2
+
3
+ module Capcode
4
+ module Helpers
5
+ # Set the path to ERB files. If this path is not set, Capcode will search in the static path.
6
+ # This method is deprecated and will be removed in version 1.0
7
+ def self.erb_path=( p )
8
+ warn "Capcode::Helpers.erb_path is deprecated and will be removed in version 1.0, please use `set :erb'"
9
+ Capcode::Configuration.set :erb, p
10
+ end
11
+
12
+ def get_binding #:nodoc:
13
+ binding
14
+ end
15
+
16
+ def render_erb( f, opts ) #:nodoc:
17
+ if @erb_path.nil?
18
+ @erb_path = Capcode::Configuration.get( :erb ) || Capcode.static()
19
+ end
20
+
21
+ f = f.to_s
22
+ if f.include? '..'
23
+ return [403, {}, '403 - Invalid path']
24
+ end
25
+
26
+ if /Windows/.match( ENV['OS'] )
27
+ unless( /.:\\/.match( @erb_path[0] ) )
28
+ @erb_path = File.expand_path( File.join(".", @erb_path) )
29
+ end
30
+ else
31
+ unless( @erb_path[0].chr == "/" )
32
+ @erb_path = File.expand_path( File.join(".", @erb_path) )
33
+ end
34
+ end
35
+
36
+ # Get Layout
37
+ layout = opts.delete(:layout)||:layout
38
+ layout_file = File.join( @erb_path, layout.to_s+".rhtml" )
39
+
40
+ # Get file
41
+ f = f + ".rhtml" if File.extname( f ) != ".rhtml"
42
+ file = File.join( @erb_path, f )
43
+
44
+ if( File.exist?( file ) )
45
+ if( File.exist?( layout_file ) )
46
+ ERB.new(open(layout_file).read).result( get_binding { |*args|
47
+ #@@__ARGS__ = args
48
+ Capcode::Helpers.args = args
49
+ ERB.new(open(file).read).result(binding)
50
+ } )
51
+ else
52
+ ERB.new(open(file).read).result(binding)
53
+ end
54
+ else
55
+ raise Capcode::RenderError, "Error rendering `erb', #{file} does not exist !"
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capcode-render-erb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregoire Lejeune
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-07 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Capcode plugin to render via Erb
17
+ email: gregoire.lejeune@free.fr
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - LICENSE
26
+ - README.rdoc
27
+ - Rakefile
28
+ - VERSION
29
+ - capcode-render-erb.gemspec
30
+ - examples/erb/cf.rhtml
31
+ - examples/erb/cf_layout.rhtml
32
+ - examples/render-erb.rb
33
+ - lib/capcode/render/erb.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/glejeune/Capcode.more/tree/master/capcode-render-erb
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Capcode plugin to render via Erb
62
+ test_files: []
63
+