nydp-html 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d01a7d3f36a0d99679fd19d725ff85a643a6b06
4
- data.tar.gz: dab0a28d59f58f676f0e646ad9a0aace4b86848d
3
+ metadata.gz: 498abe88db9496b98de631070661e49620f9bbff
4
+ data.tar.gz: b011a38450a0967b474ca4ffea4d1226ef49ecc9
5
5
  SHA512:
6
- metadata.gz: e03798eed60035ddeb288e1564a2d798b998dc7cc97c960c96dd67b6b273ac976813d4629b2c723d86ca699247eb4ac57c7ce03b734c1e78d80b3afb5ed37b94
7
- data.tar.gz: 090d0f5628bc87d76854a6306c6d5b866175be73fce881d357fd543c36fe60b3b7d0b0e2b00582a74b668a99f57a727f7883fe782ea3db633ef4266dc83cd7b5
6
+ metadata.gz: ff390f6679e54c5ba3ff4cded41251ea6db143ba928c525e95c2f3bc2cbf71aa79cfd476f40fe894dd10c1a0a7123d35081b9c38b84b0b4ac24ed93a0fa332ee
7
+ data.tar.gz: af095fb067e5dc32d28382b4d7339ead1c2ab8d95c1fdfe49a799e2812f6bfc40bb274e97ccfd01294ca9bf2aeba1213652d64c3e5b25555cda360f387f59486
@@ -92,6 +92,31 @@
92
92
  <li>item 2</li>
93
93
  <li>item 3</li>
94
94
  </ul>
95
+ ")
96
+
97
+ ("render a string with nested haml to html"
98
+ (with (a (list 1 2 3) b "hello")
99
+ (render-as-haml "%h1 HEADER
100
+
101
+ %p ~b world
102
+
103
+ ~(mapx a x (render-as-haml "
104
+ .x<
105
+ this x is ~x
106
+ .y<
107
+ and y is ~(* 2 x)
108
+ "))
109
+ "))
110
+
111
+ "<h1>HEADER</h1>
112
+ <p>hello world</p>
113
+ <div class='x'>this x is 1</div>
114
+ <div class='y'>and y is 2</div>
115
+ <div class='x'>this x is 2</div>
116
+ <div class='y'>and y is 4</div>
117
+ <div class='x'>this x is 3</div>
118
+ <div class='y'>and y is 6</div>
119
+
95
120
  ")
96
121
 
97
122
  ("render a variable to html"
@@ -32,8 +32,17 @@ module Nydp
32
32
  end
33
33
 
34
34
  class HamlToHtml
35
+ def normalise_indentation txt
36
+ lines = txt.split(/\n/).select { |line| line.strip != "" }
37
+ return txt if lines.length == 0
38
+ indentation = /^ +/.match(lines.first)
39
+ return txt unless indentation
40
+ indentation = indentation.to_s
41
+ txt.gsub(/^#{indentation}/, "")
42
+ end
43
+
35
44
  def convert_from_haml convertible
36
- Haml::Engine.new(convertible, suppress_eval: true).render
45
+ Haml::Engine.new(normalise_indentation(convertible), suppress_eval: true).render
37
46
  rescue Exception => e
38
47
  if e.line
39
48
  lines = convertible.split(/\n/)
@@ -1,5 +1,5 @@
1
1
  module Nydp
2
2
  module Html
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nydp-html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conan Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler