victor 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 657af0eb3c52eeb9014c4d4fadfaead6c1d7c62c6a3bf5e25e842946de9901d4
4
- data.tar.gz: 3d5b52371eef51e4fbb29df6bc1b8e7fe4c74fcd16d1b2f263d84b9ef294d87a
3
+ metadata.gz: b819817dc11fa725b667d3aadd3eb3a66dc2b7ab9f270fc33fda29ef93c46a86
4
+ data.tar.gz: ab063e0c9fb41c7d87ab0b18cb397b509b7a43bc441cf10649997ede67c52942
5
5
  SHA512:
6
- metadata.gz: 79c74bd26dc7b35b9d3f3ba851adf7010380d6ca690df961b3916d28aab22e5779673dca92c4822c80e9f420360d4b015ad8d9d937856c19666f45d1775bc4ab
7
- data.tar.gz: 3a48dfff5502de95253c2593e9c7b92fc500e608b32480ffd92891ab6ba965a921c29fe460e7788fe271ad334c5205de77fe0fead9c457d8c580f353ca856356
6
+ metadata.gz: 723688dd6bdd524fe2576218a6e634a7aecc6a7b44c59368f6cfa631a7eb6a032ab6974c7a45353baf911152a19e6be2347de93ea4740b66610f32e9a05e6f71
7
+ data.tar.gz: 3a8f921fc4475b882a6626009acd6cb13322180e305e8f1e16a47654d4f6125ae33870fa161aaa8da0ad40756d8823355dc94ae0961e46b26ff98383bd4341fb
data/README.md CHANGED
@@ -28,6 +28,7 @@ Table of Contents
28
28
  * [SVG Templates](#svg-templates)
29
29
  * [CSS](#css)
30
30
  * [Tagless Elements](#tagless-elements)
31
+ * [XML Encoding](#xml-encoding)
31
32
  * [Using with Rails](#using-with-rails)
32
33
  * [Related Projects](#related-projects)
33
34
 
@@ -350,6 +351,31 @@ end
350
351
  See the [targless elements example](https://github.com/DannyBen/victor/tree/master/examples#16-tagless-elements).
351
352
 
352
353
 
354
+ XML Encoding
355
+ --------------------------------------------------
356
+
357
+ Plain text values are encoded automatically:
358
+
359
+ ```ruby
360
+ svg.build do
361
+ text "Ben & Jerry's"
362
+ end
363
+ # <text>Ben &amp; Jerry's</text>
364
+ ```
365
+
366
+ If you need to use the raw, unencoded string, add `!` to the element's name:
367
+
368
+ ```ruby
369
+ svg.build do
370
+ text! "Ben & Jerry's"
371
+ end
372
+ # <text>Ben & Jerry's</text>
373
+ ```
374
+
375
+ See the [xml encoding example](https://github.com/DannyBen/victor/tree/master/examples#17-xml-encoding).
376
+
377
+
378
+
353
379
  Using with Rails
354
380
  --------------------------------------------------
355
381
 
@@ -28,12 +28,23 @@ module Victor
28
28
  value = nil
29
29
  end
30
30
 
31
+ escape = true
32
+
33
+ if name.to_s.end_with? '!'
34
+ escape = false
35
+ name = name[0..-2]
36
+ end
37
+
31
38
  attributes = Attributes.new attributes
32
39
  empty_tag = name.to_s == '_'
33
40
 
34
41
  if block_given? || value
35
42
  content.push "<#{name} #{attributes}".strip + ">" unless empty_tag
36
- value ? content.push(value.to_s.encode(xml: :text)) : yield
43
+ if value
44
+ content.push(escape ? value.to_s.encode(xml: :text) : value)
45
+ else
46
+ yield
47
+ end
37
48
  content.push "</#{name}>" unless empty_tag
38
49
  else
39
50
  content.push "<#{name} #{attributes}/>"
@@ -1,3 +1,3 @@
1
1
  module Victor
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: victor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-21 00:00:00.000000000 Z
11
+ date: 2019-07-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build SVG images with ease
14
14
  email: db@dannyben.com
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
48
- rubygems_version: 3.0.3
48
+ rubygems_version: 3.0.4
49
49
  signing_key:
50
50
  specification_version: 4
51
51
  summary: SVG Builder