hoshi 0.1.4 → 0.2.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/Rakefile +1 -1
- data/doc/examples/inline_tags.rb +20 -0
- data/lib/hoshi/view-tag-fallback.rb +3 -1
- data/lib/hoshi/view-tag.rb +2 -0
- data/lib/hoshi/view.rb +20 -6
- data/lib/hoshi/view/html4.rb +3 -3
- data/lib/hoshi/view/xhtml1.rb +1 -1
- metadata +77 -76
data/Rakefile
CHANGED
|
@@ -21,7 +21,7 @@ spec = Gem::Specification.new { |s|
|
|
|
21
21
|
s.summary = "Nice, object-oriented, first-class views."
|
|
22
22
|
s.homepage = "http://debu.gs/#{s.name}"
|
|
23
23
|
%w(metaid hpricot).each &s.method(:add_dependency)
|
|
24
|
-
s.version = '0.1
|
|
24
|
+
s.version = '0.2.1'
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
Rake::GemPackageTask.new(spec) { |pkg|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'hoshi'
|
|
2
|
+
|
|
3
|
+
puts(Hoshi::View(:html4) {
|
|
4
|
+
doc {
|
|
5
|
+
head {
|
|
6
|
+
title "Hello, world!"
|
|
7
|
+
link :rel => 'stylesheet', :href => '/css/hoshi.css'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
body {
|
|
11
|
+
h1 "Hello, world!"
|
|
12
|
+
p "This is a greeting to the world."
|
|
13
|
+
p {
|
|
14
|
+
"And #{_a 'this', :href => '/'} is an inline tag, prefixed "\
|
|
15
|
+
"by '_'."
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})
|
|
@@ -10,10 +10,12 @@ module Hoshi
|
|
|
10
10
|
if b
|
|
11
11
|
tag #{name.inspect}, #{close_type.inspect}, *opts, &b
|
|
12
12
|
else
|
|
13
|
-
tag #{name.inspect}, #{close_type.inspect}, *opts
|
|
13
|
+
tag #{name.inspect}, #{close_type.inspect}, *opts
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
EOHACK
|
|
17
|
+
# Inline tags.
|
|
18
|
+
define_method("_#{name}") { |*opts| _tag name, close_type, *opts }
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
end
|
data/lib/hoshi/view-tag.rb
CHANGED
data/lib/hoshi/view.rb
CHANGED
|
@@ -78,8 +78,8 @@ module Hoshi
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
# Create and render a view via a block.
|
|
81
|
-
def self.build(&block)
|
|
82
|
-
c = new
|
|
81
|
+
def self.build(*args, &block)
|
|
82
|
+
c = new(*args)
|
|
83
83
|
c.instance_eval(&block)
|
|
84
84
|
c.render
|
|
85
85
|
end
|
|
@@ -91,7 +91,7 @@ module Hoshi
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
# Most of these files depend on the above method definitions.
|
|
94
|
-
Dir["#{File.dirname(__FILE__)}/view/*.rb"].each
|
|
94
|
+
Dir["#{File.dirname(__FILE__)}/view/*.rb"].each { |view| require view }
|
|
95
95
|
|
|
96
96
|
def initialize
|
|
97
97
|
clear!
|
|
@@ -112,6 +112,10 @@ module Hoshi
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
def entity e
|
|
116
|
+
raw "&#{e};"
|
|
117
|
+
end
|
|
118
|
+
|
|
115
119
|
# Appends a tag to the current document, for when a tag is only needed
|
|
116
120
|
# once or has a name that is not a valid method name.
|
|
117
121
|
def tag(tname, close_type = nil, *opts, &b)
|
|
@@ -119,15 +123,25 @@ module Hoshi
|
|
|
119
123
|
|
|
120
124
|
if b
|
|
121
125
|
old, self.current = current, []
|
|
122
|
-
|
|
126
|
+
# These two lines let you do 'asdf { "jkl" }' like Markaby.
|
|
127
|
+
r = b.call
|
|
128
|
+
current << r.to_s if current.empty?
|
|
123
129
|
inside, self.current = current.map(&:to_s).join, old
|
|
124
|
-
|
|
125
|
-
inside = opts.shift
|
|
130
|
+
elsif opts.first.kind_of? String
|
|
131
|
+
inside = CGI.escapeHTML(opts.shift)
|
|
126
132
|
end
|
|
127
133
|
|
|
128
134
|
append! t.render(inside, opts.first || {})
|
|
129
135
|
end
|
|
130
136
|
|
|
137
|
+
# An inline tag; it just returns a string rather than updating the
|
|
138
|
+
# view object in place. Useful for things like
|
|
139
|
+
# p "Here is a paragraph and a #{_a 'link', :href => '/'}."
|
|
140
|
+
def _tag(tname, close_type = nil, inside = '', opts = {})
|
|
141
|
+
t = Tag.new(tname, close_type)
|
|
142
|
+
t.render(inside, opts)
|
|
143
|
+
end
|
|
144
|
+
|
|
131
145
|
# Appends something to the document. The comment, decl, and various
|
|
132
146
|
# tag methods call this.
|
|
133
147
|
def append! x
|
data/lib/hoshi/view/html4.rb
CHANGED
|
@@ -5,13 +5,13 @@ class Hoshi::View
|
|
|
5
5
|
dtd! "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" " \
|
|
6
6
|
"\"http://www.w3.org/TR/html4/strict.dtd\">"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
tags *%w(a address applet area base basefont bdo blockquote body br
|
|
8
|
+
tags *%w(a address applet area b base basefont bdo blockquote body
|
|
10
9
|
button caption center col colgroup dd div dl dt fieldset font
|
|
11
10
|
form frame frameset h1 h2 h3 h4 h5 h6 head hr html iframe img
|
|
12
11
|
input isindex label legend li link map meta noframes noscript
|
|
13
12
|
object ol optgroup option p param pre q script select span
|
|
14
|
-
style table tbody textarea tfoot thead title tr ul)
|
|
13
|
+
style table tbody textarea tfoot thead title tr td ul nobr)
|
|
14
|
+
open_tags *%w(br)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
data/lib/hoshi/view/xhtml1.rb
CHANGED
|
@@ -12,6 +12,6 @@ class Hoshi::View
|
|
|
12
12
|
label legend li link map menu meta noframes noscript object ol
|
|
13
13
|
optgroup option p param pre q s samp script select small span
|
|
14
14
|
strike strong style sub sup table tbody td textarea tfoot th
|
|
15
|
-
thead title tr tt u ul var)
|
|
15
|
+
thead title tr tt u ul var nobr)
|
|
16
16
|
end
|
|
17
17
|
end
|
metadata
CHANGED
|
@@ -1,106 +1,107 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
3
|
-
requirements:
|
|
4
|
-
- - '>='
|
|
5
|
-
- !ruby/object:Gem::Version
|
|
6
|
-
version: "0"
|
|
7
|
-
version:
|
|
8
|
-
email: pete.elmore@gmail.com
|
|
9
|
-
cert_chain: []
|
|
10
|
-
|
|
11
|
-
summary: Nice, object-oriented, first-class views.
|
|
12
|
-
post_install_message:
|
|
13
|
-
extra_rdoc_files:
|
|
14
|
-
- doc/README
|
|
15
|
-
- doc/TODO
|
|
16
|
-
- doc/LICENSE
|
|
17
|
-
homepage: http://debu.gs/hoshi
|
|
18
|
-
signing_key:
|
|
19
2
|
name: hoshi
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Pete Elmore
|
|
22
8
|
autorequire:
|
|
23
|
-
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-05-13 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: metaid
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: "0"
|
|
24
|
+
version:
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: hpricot
|
|
27
|
+
type: :runtime
|
|
28
|
+
version_requirement:
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: "0"
|
|
34
|
+
version:
|
|
35
|
+
description:
|
|
36
|
+
email: pete.elmore@gmail.com
|
|
24
37
|
executables:
|
|
25
38
|
- html2hoshi
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
extensions: []
|
|
40
|
+
|
|
41
|
+
extra_rdoc_files:
|
|
42
|
+
- doc/LICENSE
|
|
43
|
+
- doc/TODO
|
|
44
|
+
- doc/README
|
|
29
45
|
files:
|
|
30
|
-
- lib/html2hoshi.rb
|
|
31
|
-
- lib/hoshi.rb
|
|
32
46
|
- lib/hoshi
|
|
33
|
-
- lib/hoshi/monkey_patches.rb
|
|
34
47
|
- lib/hoshi/view
|
|
35
|
-
- lib/hoshi/view
|
|
36
|
-
- lib/hoshi/tag.rb
|
|
37
|
-
- lib/hoshi/view-tag-fallback.rb
|
|
38
|
-
- lib/hoshi/view.rb
|
|
39
|
-
- lib/hoshi/view/html.rb
|
|
40
|
-
- lib/hoshi/view/xhtml1_strict.rb
|
|
41
|
-
- lib/hoshi/view/xhtml1_frameset.rb
|
|
48
|
+
- lib/hoshi/view/xhtml2.rb
|
|
42
49
|
- lib/hoshi/view/html4_transitional.rb
|
|
43
|
-
- lib/hoshi/view/xhtml.rb
|
|
44
|
-
- lib/hoshi/view/html3.rb
|
|
45
50
|
- lib/hoshi/view/html4_frameset.rb
|
|
46
51
|
- lib/hoshi/view/xhtml1.rb
|
|
52
|
+
- lib/hoshi/view/html3.rb
|
|
53
|
+
- lib/hoshi/view/xhtml1_frameset.rb
|
|
47
54
|
- lib/hoshi/view/html4.rb
|
|
48
|
-
- lib/hoshi/view/xhtml2.rb
|
|
49
|
-
- lib/hoshi/view/xhtml1_transitional.rb
|
|
50
55
|
- lib/hoshi/view/rss2.rb
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
56
|
+
- lib/hoshi/view/html.rb
|
|
57
|
+
- lib/hoshi/view/xhtml.rb
|
|
58
|
+
- lib/hoshi/view/xhtml1_strict.rb
|
|
59
|
+
- lib/hoshi/view/xhtml1_transitional.rb
|
|
60
|
+
- lib/hoshi/view-tag-fallback.rb
|
|
61
|
+
- lib/hoshi/monkey_patches.rb
|
|
62
|
+
- lib/hoshi/view.rb
|
|
63
|
+
- lib/hoshi/tag.rb
|
|
64
|
+
- lib/hoshi/view-tag.rb
|
|
65
|
+
- lib/hoshi.rb
|
|
66
|
+
- lib/html2hoshi.rb
|
|
54
67
|
- doc/LICENSE
|
|
55
|
-
- doc/
|
|
68
|
+
- doc/TODO
|
|
69
|
+
- doc/examples
|
|
56
70
|
- doc/examples/trivial.rb
|
|
57
71
|
- doc/examples/blocks.rb
|
|
58
72
|
- doc/examples/env.cgi
|
|
73
|
+
- doc/examples/inline_tags.rb
|
|
59
74
|
- doc/examples/feed.rb
|
|
60
75
|
- doc/examples/rss2.rb
|
|
76
|
+
- doc/examples/layouts.rb
|
|
77
|
+
- doc/README
|
|
61
78
|
- bin/html2hoshi
|
|
62
79
|
- Rakefile
|
|
80
|
+
has_rdoc: true
|
|
81
|
+
homepage: http://debu.gs/hoshi
|
|
82
|
+
post_install_message:
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: "0"
|
|
92
|
+
version:
|
|
63
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
94
|
requirements:
|
|
65
|
-
- -
|
|
95
|
+
- - ">="
|
|
66
96
|
- !ruby/object:Gem::Version
|
|
67
97
|
version: "0"
|
|
68
98
|
version:
|
|
69
|
-
extensions: []
|
|
70
|
-
|
|
71
|
-
rubygems_version: 1.3.1
|
|
72
99
|
requirements: []
|
|
73
100
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
rubyforge_project: hoshi-view
|
|
102
|
+
rubygems_version: 1.3.1
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 2
|
|
105
|
+
summary: Nice, object-oriented, first-class views.
|
|
78
106
|
test_files: []
|
|
79
107
|
|
|
80
|
-
version: !ruby/object:Gem::Version
|
|
81
|
-
version: 0.1.4
|
|
82
|
-
require_paths:
|
|
83
|
-
- lib
|
|
84
|
-
dependencies:
|
|
85
|
-
- !ruby/object:Gem::Dependency
|
|
86
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - '>='
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: "0"
|
|
91
|
-
version:
|
|
92
|
-
type: :runtime
|
|
93
|
-
version_requirement:
|
|
94
|
-
name: metaid
|
|
95
|
-
- !ruby/object:Gem::Dependency
|
|
96
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
97
|
-
requirements:
|
|
98
|
-
- - '>='
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: "0"
|
|
101
|
-
version:
|
|
102
|
-
type: :runtime
|
|
103
|
-
version_requirement:
|
|
104
|
-
name: hpricot
|
|
105
|
-
bindir: bin
|
|
106
|
-
has_rdoc: true
|