nydp-html 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lisp/html-010-tools.nydp +10 -9
- data/lib/lisp/tests/haml-tests.nydp +14 -0
- data/lib/lisp/tests/html-tag-tests.nydp +13 -1
- data/lib/nydp/html.rb +1 -0
- data/lib/nydp/html/version.rb +1 -1
- data/nydp-html.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b857483d711fd8feba7b0d9e074f0661201d3c
|
4
|
+
data.tar.gz: da7407f42604da72d680079a24d1a4698bd7bf9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c616362e5206cac57a1363cfef7f6c145bcb12da16ffcbd9eb38b296fe51a246df7fa5d0453c3b33f2e3bd9440ab7a4f8de3e3e23bb56ccf65afd04f7e4b9ce
|
7
|
+
data.tar.gz: 0e144d603a24da5ea0b7a32eaca597be15e291c4859eda624ddf9e5b1860e5f06aabcb0f264f244b9ef92c575910793c0e78ff2dee1ead4bbf1d1b7ca942116e
|
@@ -20,7 +20,7 @@
|
|
20
20
|
(fn (piece)
|
21
21
|
(if (isa 'string piece)
|
22
22
|
piece
|
23
|
-
(let key (j "
|
23
|
+
(let key (j "hsf:" (seq) ":hsf")
|
24
24
|
(hash-set hsh key `(interpolate ,piece))
|
25
25
|
(j esc sep key sep esc)))))
|
26
26
|
|
@@ -101,27 +101,28 @@
|
|
101
101
|
|
102
102
|
(def as-tag-attrs (attrs)
|
103
103
|
(let hsh (or attrs (hash))
|
104
|
-
(joinstr ""
|
105
|
-
|
106
|
-
(hash-keys hsh)))))
|
104
|
+
(j:map (fn (k) " ~|k|='~(joinstr " " hsh.,k)'")
|
105
|
+
(hash-keys hsh))))
|
107
106
|
|
108
107
|
(def html-tag/ (name attrs) "<~|name|~(as-tag-attrs attrs)/>")
|
109
108
|
(def html-tag (name attrs . content)
|
110
109
|
(let formatted (map default-format content)
|
111
|
-
"<~|name|~(as-tag-attrs attrs)>~(
|
110
|
+
"<~|name|~(as-tag-attrs attrs)>~(j formatted)</~|name|>"))
|
112
111
|
(def img (src) (html-tag/ "img" { src src }))
|
113
112
|
(def link-to (txt path attrs) (html-tag "a" (hash-merge { href path } (or attrs (hash))) txt))
|
114
113
|
(def html-tag-fn (name attrs) (fn content (apply html-tag name attrs content)))
|
115
114
|
|
116
115
|
(def build-html-tag-fn (tagname attrs)
|
117
|
-
|
116
|
+
(if (string-match tagname ".+/$")
|
117
|
+
`(curry html-tag/ ,(string-replace "/$" "" tagname) ,(if attrs `(brace-list ,@attrs)))
|
118
|
+
`(curry html-tag ,tagname ,(if attrs `(brace-list ,@attrs)))))
|
118
119
|
|
119
120
|
(def html-percent-syntax (tagname attrs)
|
120
121
|
(if (caris 'dot-syntax tagname)
|
121
122
|
(let dot-params (cdr tagname)
|
122
|
-
(build-html-tag-fn (car dot-params)
|
123
|
+
(build-html-tag-fn (to-string:car dot-params)
|
123
124
|
(+ `(class ,(joinstr " " (cdr dot-params))) attrs)))
|
124
|
-
(build-html-tag-fn tagname attrs)))
|
125
|
+
(build-html-tag-fn (to-string tagname) attrs)))
|
125
126
|
|
126
127
|
(mac percent-syntax names
|
127
128
|
(html-percent-syntax (cadr names) nil))
|
@@ -129,5 +130,5 @@
|
|
129
130
|
(define-prefix-list-macro "^%.+" vars expr
|
130
131
|
; allows (%a(href "/fr/index") "click" name)
|
131
132
|
; as shortcut for (html-tag "a" { href "/fr/index" } "click " name)
|
132
|
-
(let tag-name (car:parse:
|
133
|
+
(let tag-name (car:parse:j:cdr:string-split vars)
|
133
134
|
(html-percent-syntax tag-name expr)))
|
@@ -43,6 +43,20 @@
|
|
43
43
|
"</li>\n <li>item " (interpolate (assign counter (+ counter 1)))
|
44
44
|
"</li>\n</ul>\n"))
|
45
45
|
|
46
|
+
("compile a string with interpolations inside embedded textile to an instruction to generate haml"
|
47
|
+
(pre-compile '(render-as-haml "%h1 HEADER
|
48
|
+
|
49
|
+
:textile
|
50
|
+
* a is ~a
|
51
|
+
* b is ~b
|
52
|
+
* c is ~(c 3)
|
53
|
+
"))
|
54
|
+
|
55
|
+
(string-pieces "<h1>HEADER</h1>\n<ul>\n\t<li>a is " (interpolate a)
|
56
|
+
"</li>\n\t<li>b is " (interpolate b)
|
57
|
+
"</li>\n\t<li>c is " (interpolate (c 3))
|
58
|
+
"</li>\n</ul>\n"))
|
59
|
+
|
46
60
|
("compile a function invocation to render as haml"
|
47
61
|
(pre-compile '(render-as-haml a))
|
48
62
|
(haml-to-html a))
|
@@ -20,6 +20,10 @@
|
|
20
20
|
(%p "hello, world")
|
21
21
|
"<p>hello, world</p>")
|
22
22
|
|
23
|
+
("generates a self-closing html tag"
|
24
|
+
(%br/)
|
25
|
+
"<br/>")
|
26
|
+
|
23
27
|
("generates nested html tags"
|
24
28
|
(%p "hello " (%b "you") " over " (%i "there"))
|
25
29
|
"<p>hello <b>you</b> over <i>there</i></p>")
|
@@ -38,13 +42,21 @@
|
|
38
42
|
|
39
43
|
("does not insert empty 'brace-list for no attributes"
|
40
44
|
(pre-compile '(%p foo))
|
41
|
-
((curry html-tag
|
45
|
+
((curry html-tag "p" nil) foo)))
|
42
46
|
|
43
47
|
(examples-for prefix-list
|
44
48
|
("generates a simple html tag with attributes"
|
45
49
|
(%a(href "/fr/index") "click here")
|
46
50
|
"<a href='/fr/index'>click here</a>")
|
47
51
|
|
52
|
+
("generates a self-closing html tag with attributes"
|
53
|
+
(%img/(src "/smile.png"))
|
54
|
+
"<img src='/smile.png'/>")
|
55
|
+
|
56
|
+
("generates a self-closing html tag with attributes and classes"
|
57
|
+
(%img/.round(src "/smile.png"))
|
58
|
+
"<img class='round' src='/smile.png'/>")
|
59
|
+
|
48
60
|
("generates nested html tags with attributes"
|
49
61
|
(%p(class 'important)
|
50
62
|
"read this and "
|
data/lib/nydp/html.rb
CHANGED
data/lib/nydp/html/version.rb
CHANGED
data/nydp-html.gemspec
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '4.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: haml-contrib
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: RedCloth
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|