xrb 0.2.0 → 0.3.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/lib/xrb/builder.rb CHANGED
@@ -37,6 +37,16 @@ module XRB
37
37
  # This is a bit of a hack... but is required for existing specs to pass:
38
38
  self.to_s == other.to_s
39
39
  end
40
+
41
+ def >> block
42
+ if block
43
+ Template.buffer(block.binding) << self
44
+
45
+ return nil
46
+ else
47
+ return self
48
+ end
49
+ end
40
50
  end
41
51
 
42
52
  # A helper to generate fragments of markup.
@@ -49,12 +59,9 @@ module XRB
49
59
  return Fragment.new(block)
50
60
  end
51
61
 
52
- if output.is_a?(Builder)
53
- block.call(output)
54
- else
55
- block.call(Builder.new(output))
56
- end
62
+ block.call(output)
57
63
 
64
+ # We explicitly return nil here as we don't want to append the output twice.
58
65
  return nil
59
66
  end
60
67
 
@@ -103,7 +110,7 @@ module XRB
103
110
  end
104
111
 
105
112
  def doctype(attributes = 'html')
106
- @output << "<!DOCTYPE #{attributes}>\n"
113
+ @output << "<!doctype #{attributes}>\n"
107
114
  end
108
115
 
109
116
  # Begin a block tag.
data/lib/xrb/entities.xrb CHANGED
@@ -1,22 +1,7 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
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 deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # 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 THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2016-2024, by Samuel Williams.
20
5
 
21
6
  module XRB
22
7
  # We only support a small subset of markup entities.