tagz 8.1.0 → 8.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/tagz.rb +18 -4
  2. data/tagz.gemspec +1 -1
  3. data/test/tagz_test.rb +3 -1
  4. metadata +4 -4
@@ -4,7 +4,7 @@ unless defined? Tagz
4
4
  #
5
5
  module Tagz
6
6
  def Tagz.version()
7
- '8.1.0'
7
+ '8.2.0'
8
8
  end
9
9
 
10
10
  def Tagz.description
@@ -189,6 +189,10 @@ unless defined? Tagz
189
189
  }
190
190
  }
191
191
 
192
+ module HtmlSafe
193
+ attr_accessor :html_safe
194
+ end
195
+
192
196
  class Document < ::String
193
197
  def Document.for other
194
198
  Document === other ? other : Document.new(other.to_s)
@@ -207,7 +211,11 @@ unless defined? Tagz
207
211
  when Document
208
212
  super string.to_s
209
213
  else
210
- super Tagz.escape_content(string)
214
+ if string.respond_to?(:html_safe)
215
+ super string.to_s
216
+ else
217
+ super Tagz.escape_content(string)
218
+ end
211
219
  end
212
220
  self
213
221
  end
@@ -217,8 +225,9 @@ unless defined? Tagz
217
225
  end
218
226
  #alias_method 'concat', '<<'
219
227
 
220
- def escape(*strings)
221
- Tagz.xchar.escape(strings.join)
228
+ def escape(string)
229
+ return string if string.respond_to?(:html_safe)
230
+ Tagz.xchar.escape(string)
222
231
  end
223
232
  alias_method 'h', 'escape'
224
233
 
@@ -226,6 +235,10 @@ unless defined? Tagz
226
235
  write "#{ string }\n"
227
236
  end
228
237
 
238
+ def raw(string)
239
+ push Document.for(string)
240
+ end
241
+
229
242
  def document
230
243
  self
231
244
  end
@@ -347,6 +360,7 @@ unless defined? Tagz
347
360
  VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF), (0xE000..0xFFFD), (0x10000..0x10FFFF)]
348
361
 
349
362
  def XChar.escape(string)
363
+ return string if string.respond_to?(:html_safe)
350
364
  string.unpack('U*').map{|n| xchr(n)}.join # ASCII, UTF-8
351
365
  rescue
352
366
  string.unpack('C*').map{|n| xchr(n)}.join # ISO-8859-1, WIN-1252
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "tagz"
6
- spec.version = "8.1.0"
6
+ spec.version = "8.2.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "tagz"
9
9
  spec.description = "\n tagz.rb is generates html, xml, or any sgml variant like a small ninja\n running across the backs of a herd of giraffes swatting of heads like\n a mark-up weedwacker. weighing in at less than 300 lines of code\n tagz.rb adds an html/xml/sgml syntax to ruby that is both unobtrusive,\n safe, and available globally to objects without the need for any\n builder or superfluous objects. tagz.rb is designed for applications\n that generate html to be able to do so easily in any context without\n heavyweight syntax or scoping issues, like a ninja sword through\n butter.\n\n"
@@ -660,13 +660,15 @@ class TagzTest < Test::Unit::TestCase
660
660
  tagz << 'e>f'
661
661
  __
662
662
  tagz.push 'g>h'
663
+ __
664
+ tagz.raw '<tag />'
663
665
  }
664
666
  end
665
667
  }.new
666
668
 
667
669
  actual = nil
668
670
  assert_nothing_raised{ actual=c.a}
669
- expected = "<div>\na&gt;b\nc>d\ne&gt;f\ng>h</div>"
671
+ expected = "<div>\na&gt;b\nc>d\ne&gt;f\ng>h\n<tag /></div>"
670
672
  assert_equal expected, actual
671
673
  end
672
674
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 91
4
+ hash: 87
5
5
  prerelease:
6
6
  segments:
7
7
  - 8
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 8.1.0
10
+ version: 8.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ara T. Howard
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-31 00:00:00 -07:00
18
+ date: 2011-02-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21