sinatra-haml 0.1.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/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.1.0 / 2008-01-30
2
+
3
+ * First release
4
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/sinatra/renderer/haml.rb
6
+ lib/version.rb
7
+ test/test_sinatra_haml_renderer.rb
data/README.txt ADDED
@@ -0,0 +1,49 @@
1
+ HamlSinatraRenderer
2
+ http://codebrulee.rubyforge.org
3
+ by kevin smith
4
+
5
+ == DESCRIPTION:
6
+
7
+ A Haml renderer for the Sinatra (http://sinatra.rubyforge.org) web framework.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Supports all the rendering features of Sinatra
12
+
13
+ == SYNOPSIS:
14
+
15
+ require 'haml_sinatra_renderer'
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * Sinatra
20
+ * Haml
21
+
22
+ == INSTALL:
23
+
24
+ * sudo gem install haml_sinatra_renderer
25
+
26
+ == LICENSE:
27
+
28
+ (The MIT License)
29
+
30
+ Copyright (c) 2008
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/version.rb'
6
+
7
+ Hoe.new('sinatra-haml', HamlSinatraRenderer::VERSION) do |p|
8
+ p.rubyforge_name = 'codebrulee'
9
+ p.author = 'kevin smith'
10
+ p.email = 'kevin@codebrulee.com'
11
+ p.summary = 'A Haml renderer for Sinatra'
12
+ p.description = 'A Haml renderer for Sinatra'
13
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.extra_deps = {"sinatra" => "> 0.1.7"}
16
+ end
17
+
18
+ desc "run haml renderer test"
19
+ task :test_renderer do
20
+ system "ruby #{File.dirname(__FILE__)}/test/test_haml_sinatra_renderer.rb"
21
+ end
@@ -0,0 +1,23 @@
1
+ module Sinatra
2
+ module Haml
3
+ def haml(template, options = {})
4
+ Renderer.new.render(template, options)
5
+ end
6
+
7
+ class Renderer
8
+ require 'haml'
9
+ include Sinatra::RenderingHelpers
10
+
11
+ def ext
12
+ :haml
13
+ end
14
+ alias :haml :render # so that we can render partials w/ the haml method
15
+
16
+ private
17
+ def _evaluate_render(template, options={})
18
+ ::Haml::Engine.new(template,options).render(self)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ Sinatra::EventContext.send(:include, Sinatra::Haml)
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ class HamlSinatraRenderer
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,78 @@
1
+ require "/Users/kevinsmith/development/testbed/sinatra/test/helper"
2
+ require File.dirname(__FILE__) + "/../lib/sinatra/renderer/haml"
3
+
4
+ context "haml rendering" do
5
+
6
+ setup do
7
+ @view_directory = File.dirname(__FILE__) + '/views'
8
+ @layout = <<-LAYOUT_CODE
9
+ get '/inline_with_layout' do
10
+ haml "%div Haml!", options
11
+ end
12
+
13
+ get '/file_with_layout' do
14
+ haml :foo, options
15
+ end
16
+
17
+ get_it '/inline_with_layout'
18
+ should.be.ok
19
+ body.should.equal "<div><div>Haml!</div></div>\n"
20
+
21
+ get_it '/file_with_layout'
22
+ should.be.ok
23
+ body.should.equal "<div><strong>hello haml!</strong></div>\n"
24
+ LAYOUT_CODE
25
+ end
26
+
27
+ specify "can render inline" do
28
+ get '/inline_haml' do
29
+ haml '%div Haml!'
30
+ end
31
+
32
+ get_it '/inline_haml'
33
+ should.be.ok
34
+ body.should.equal "<div>Haml!</div>\n"
35
+ end
36
+
37
+ specify "can render from file" do
38
+ get '/file_haml' do
39
+ haml :foo, {:views_directory => @view_directory}
40
+ end
41
+
42
+ get_it '/file_haml'
43
+ should.be.ok
44
+ body.should.equal "<strong>hello haml!</strong>\n"
45
+ end
46
+
47
+ specify "can do partials" do
48
+ get '/partial_test' do
49
+ haml "%span= haml :foo", {:views_directory => @view_directory}
50
+ end
51
+
52
+ get_it '/partial_test'
53
+ should.be.ok
54
+ body.should.equal "<span><strong>hello haml!</strong></span>\n"
55
+ end
56
+
57
+
58
+ specify "can do file-based layout" do
59
+ options = {:views_directory => @view_directory, :layout => :layout}
60
+ instance_eval(@layout)
61
+ end
62
+
63
+ specify "can do inline layout" do
64
+ options = {:views_directory => @view_directory}
65
+ layout do
66
+ %Q{%div= @content}
67
+ end
68
+ instance_eval(@layout)
69
+ end
70
+
71
+ specify "can do named layouts" do
72
+ options = {:views_directory => @view_directory, :layout => :dude}
73
+ layout :dude do
74
+ %Q{%div= @content}
75
+ end
76
+ instance_eval(@layout)
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-haml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kevin smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.1.7
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: hoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.4.0
32
+ version:
33
+ description: A Haml renderer for Sinatra
34
+ email: kevin@codebrulee.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - History.txt
41
+ - Manifest.txt
42
+ - README.txt
43
+ files:
44
+ - History.txt
45
+ - Manifest.txt
46
+ - README.txt
47
+ - Rakefile
48
+ - lib/sinatra/renderer/haml.rb
49
+ - lib/version.rb
50
+ - test/test_sinatra_haml_renderer.rb
51
+ has_rdoc: true
52
+ homepage: http://codebrulee.rubyforge.org
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --main
56
+ - README.txt
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ requirements: []
72
+
73
+ rubyforge_project: codebrulee
74
+ rubygems_version: 1.0.1
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: A Haml renderer for Sinatra
78
+ test_files:
79
+ - test/test_sinatra_haml_renderer.rb