sinatra-block-html 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -0
- data/COPYING +18 -0
- data/README.rdoc +52 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/lib/sinatra-block-html.rb +31 -0
- metadata +69 -0
data/CHANGELOG
ADDED
File without changes
|
data/COPYING
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2009 Jun Kikuchi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
= sinatra-block-html
|
2
|
+
|
3
|
+
こんな感じのレイアウトとビューを作って
|
4
|
+
|
5
|
+
views/layout.bhtml
|
6
|
+
html {
|
7
|
+
tag(:head) {
|
8
|
+
title.text @title
|
9
|
+
}
|
10
|
+
tag(:body) {
|
11
|
+
self << yield
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
views/index.bhtml
|
16
|
+
h1.text @title
|
17
|
+
p.text @contents
|
18
|
+
|
19
|
+
Sinatra の DSL で出力
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'sinatra'
|
23
|
+
require 'sinatra-block-html'
|
24
|
+
|
25
|
+
get '/' do
|
26
|
+
@title = 'Hello World!'
|
27
|
+
@contents = 'こんにちは!'
|
28
|
+
|
29
|
+
bhtml :index
|
30
|
+
end
|
31
|
+
|
32
|
+
Sinatra::Base で出力
|
33
|
+
|
34
|
+
require 'rubygems'
|
35
|
+
require 'sinatra'
|
36
|
+
require 'sinatra/base'
|
37
|
+
require 'sinatra-block-html'
|
38
|
+
|
39
|
+
class App < Sinatra::Base
|
40
|
+
get '/' do
|
41
|
+
@title = 'Hello World!'
|
42
|
+
@contents = 'こんにちは!'
|
43
|
+
|
44
|
+
bhtml :index
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
use App
|
49
|
+
|
50
|
+
すると、こんな HTML が出力されます
|
51
|
+
|
52
|
+
<html><head><title>Hello World!</title></head><body><h1>Hello World!</h1><p>こんにちは!</p></body></html>
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
NAME = 'sinatra-block-html'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = NAME
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = NAME
|
12
|
+
s.description = NAME
|
13
|
+
s.author = "Jun Kikuchi"
|
14
|
+
s.email = "kikuchi@bonnou.com"
|
15
|
+
s.homepage = "http://github.com/JunKikuchi/sinatra-block-html"
|
16
|
+
s.files = %w(
|
17
|
+
COPYING CHANGELOG README.rdoc Rakefile VERSION
|
18
|
+
) + Dir.glob("{bin,doc,spec,lib}/**/*")
|
19
|
+
s.require_path = "lib"
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.add_dependency('block-html','>= 0.0.3')
|
22
|
+
end
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new do |t|
|
28
|
+
#t.spec_opts = ['-c --format specdoc']
|
29
|
+
t.spec_opts = ['-c']
|
30
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.4
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'block-html'
|
3
|
+
|
4
|
+
module Sinatra
|
5
|
+
module BlockHTML
|
6
|
+
def bhtml(template=nil, options={}, locals={}, &block)
|
7
|
+
require_warn('BlockHTML') unless defined?(::BlockHTML)
|
8
|
+
|
9
|
+
options, template = template, nil if template.is_a?(Hash)
|
10
|
+
template = lambda { block } if template.nil?
|
11
|
+
render(:bhtml, template, options, locals).to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
def render_bhtml(template, data, options, locals, &block)
|
16
|
+
if data.respond_to?(:to_str)
|
17
|
+
::BlockHTML.new(self) do
|
18
|
+
instance_eval(data)
|
19
|
+
end
|
20
|
+
elsif data.kind_of?(Proc)
|
21
|
+
::BlockHTML.new(self, &data)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
helpers BlockHTML
|
27
|
+
|
28
|
+
class Base
|
29
|
+
include Sinatra::BlockHTML
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-block-html
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jun Kikuchi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-03 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: block-html
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.3
|
24
|
+
version:
|
25
|
+
description: sinatra-block-html
|
26
|
+
email: kikuchi@bonnou.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- CHANGELOG
|
35
|
+
- COPYING
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- VERSION
|
39
|
+
- lib/sinatra-block-html.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/JunKikuchi/sinatra-block-html
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --charset=UTF-8
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.3.5
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: sinatra-block-html
|
68
|
+
test_files: []
|
69
|
+
|