rubified 0.1.1 → 0.1.2

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/lib/ext/object.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  class Object
2
- def to_html
3
- to_s
2
+ def to_html(embedded)
3
+ str = to_s
4
+ if str[-1] == "\n"
5
+ str
6
+ else
7
+ str << "\n"
8
+ end
4
9
  end
5
10
  end
@@ -33,23 +33,13 @@ module Rubified
33
33
  module Canvas
34
34
  # Add a method for a specific XML/HTML tag class.
35
35
  def self.add_tag_method(tclass)
36
- n = tclass.to_s.split("::").last.downcase
37
- #puts n
38
- =begin
39
- define_method(n) do |params={}, &block|
40
- # Figure out what class to use by the method name.
41
- #puts __method__
42
- tagclass = Rubified::Tag.const_get((__method__).capitalize)
43
- # Create a new tag then run it
44
- tagclass.new(params).to_html(&block)
45
- end
46
- =end
36
+ n = "tag_" + tclass.to_s.split("::").last.downcase
47
37
  eval "
48
- def #{n}(params={}, &block)
38
+ def #{n}(params={}, embedded=false, &block)
49
39
  # Determine what class to use by the method name.
50
40
  tagclass = #{tclass}
51
41
  # Create a new tag then convert it.
52
- tagclass.new(params).to_html(&block)
42
+ tagclass.new(params).to_html(embedded, &block)
53
43
  end
54
44
  "
55
45
  end
data/lib/rubified/tag.rb CHANGED
@@ -9,26 +9,26 @@ class Rubified::Tag
9
9
  end
10
10
 
11
11
  # The arguments to this method is a hash key of the parameters to the HTML tag.
12
- def initialize(params={})
12
+ def initialize(params={}, embedded=false)
13
13
  # The name of the tag, e.g. font
14
14
  @tname = self.class.to_s.split("::").last.downcase
15
15
  # Any parameters of this tag, e.g. if you have the HTML tag:
16
16
  # <div id="foo" class="bar">
17
17
  # then the parameters would be +id+ and +class+.
18
- @params = params
18
+ @params, @embedded = params, embedded
19
19
  end
20
20
 
21
21
  # Dumps this tag to an HTML string.
22
- def to_html
22
+ def to_html(embedded)
23
23
  pstring = ""
24
24
  @params.each {|key, val| pstring << " #{key}=\"#{val}\""}
25
- result = "<#{@tname}#{pstring}>"
25
+ raw = "<#{@tname}#{pstring}>\n"
26
26
  if block_given?
27
- result << yield.to_html
27
+ raw << (yield.to_html(true))
28
28
  end
29
29
  if self.class::Paired
30
- result << "</#{@tname}>"
30
+ raw << "</#{@tname}>\n"
31
31
  end
32
- result
32
+ raw
33
33
  end
34
34
  end
data/lib/rubified/tags.rb CHANGED
@@ -3,15 +3,23 @@ tags = {
3
3
  :html=>true,
4
4
  :head=>true,
5
5
  :body=>true,
6
+ :title=>true,
6
7
  :p=>true,
7
8
  :div=>true,
8
9
  :span=>true,
10
+ :span=>true,
9
11
  :font=>true,
10
12
  :b=>true,
11
13
  :i=>true,
12
14
  :tt=>true,
15
+ :h1=>true,
16
+ :h2=>true,
17
+ :h3=>true,
18
+ :h4=>true,
13
19
 
14
- :img=>false
20
+ :img=>false,
21
+ :br=>false,
22
+ :link=>false
15
23
  }
16
24
 
17
25
  tags.each {|tag, paired|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rubified
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - J. Wostenberg
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-09 00:00:00 -07:00
13
+ date: 2012-02-11 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16