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 +4 -4
- data/lib/lisp/tests/haml-tests.nydp +25 -0
- data/lib/nydp/html.rb +10 -1
- data/lib/nydp/html/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 498abe88db9496b98de631070661e49620f9bbff
|
4
|
+
data.tar.gz: b011a38450a0967b474ca4ffea4d1226ef49ecc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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"
|
data/lib/nydp/html.rb
CHANGED
@@ -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/)
|
data/lib/nydp/html/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|