express_templates 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core_extensions/proc.rb +72 -20
- data/lib/express_templates/compiler.rb +9 -1
- data/lib/express_templates/components/base.rb +1 -1
- data/lib/express_templates/components/capabilities/building.rb +8 -0
- data/lib/express_templates/components/capabilities/conditionality.rb +8 -6
- data/lib/express_templates/components/capabilities/configurable.rb +3 -4
- data/lib/express_templates/components/capabilities/iterating.rb +18 -23
- data/lib/express_templates/components/capabilities/parenting.rb +4 -18
- data/lib/express_templates/components/capabilities/rendering.rb +2 -65
- data/lib/express_templates/components/capabilities/templating.rb +24 -22
- data/lib/express_templates/components/capabilities/wrapping.rb +23 -39
- data/lib/express_templates/components/column.rb +1 -1
- data/lib/express_templates/components/for_each.rb +28 -0
- data/lib/express_templates/components/form_for.rb +19 -0
- data/lib/express_templates/components/form_rails_support.rb +1 -1
- data/lib/express_templates/components/null_wrap.rb +9 -0
- data/lib/express_templates/components/row.rb +1 -1
- data/lib/express_templates/components/table_for.rb +119 -0
- data/lib/express_templates/components/tree_for.rb +41 -0
- data/lib/express_templates/components/unless_block.rb +40 -0
- data/lib/express_templates/components.rb +4 -0
- data/lib/express_templates/expander.rb +15 -4
- data/lib/express_templates/indenter.rb +8 -5
- data/lib/express_templates/markup/tag.rb +62 -30
- data/lib/express_templates/markup/wrapper.rb +1 -1
- data/lib/express_templates/version.rb +1 -1
- data/test/components/base_test.rb +5 -38
- data/test/components/conditionality_test.rb +1 -1
- data/test/components/configurable_test.rb +2 -2
- data/test/components/container_test.rb +1 -1
- data/test/components/iterating_test.rb +30 -9
- data/test/components/table_for_test.rb +116 -0
- data/test/core_extensions/proc_test.rb +35 -5
- data/test/dummy/log/test.log +645 -0
- data/test/fixtures/{a_big_page.html → a_big_page2.html} +0 -0
- data/test/indenter_test.rb +6 -4
- data/test/markup/tag_test.rb +15 -2
- data/test/performance_test.rb +1 -1
- data/test/test_helper.rb +2 -0
- metadata +26 -3
data/test/indenter_test.rb
CHANGED
@@ -5,8 +5,10 @@ class IndenterTest < ActiveSupport::TestCase
|
|
5
5
|
Indenter = ExpressTemplates::Indenter
|
6
6
|
|
7
7
|
test ".for(:name) takes a block receiving whitespace" do
|
8
|
-
|
9
|
-
|
8
|
+
Indenter.for(:foo) do
|
9
|
+
assert_equal "\n ", Indenter.for(:foo) { |indent, indent_with_newline| indent_with_newline }
|
10
|
+
assert_equal " ", Indenter.for(:foo) { |indent, indent_with_newline| indent }
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
test "nesting blocks increases whitespace accordingly" do
|
@@ -15,11 +17,11 @@ class IndenterTest < ActiveSupport::TestCase
|
|
15
17
|
ws2
|
16
18
|
end
|
17
19
|
end
|
18
|
-
assert_equal "
|
20
|
+
assert_equal " ", nested_whitespace
|
19
21
|
end
|
20
22
|
|
21
23
|
test ".for(:name) returns current indent without newline when block is not given" do
|
22
|
-
assert_equal "
|
24
|
+
assert_equal "", Indenter.for(:foo) { |_| Indenter.for(:foo) }
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
data/test/markup/tag_test.rb
CHANGED
@@ -14,6 +14,10 @@ class TagTest < ActiveSupport::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
|
+
# NOTE: Due to formatting html leading newlines may be
|
18
|
+
# required for test values. These are stripped for the
|
19
|
+
# first tag during ExpressTemplates.compile
|
20
|
+
|
17
21
|
test "#macro_name returns the name of the class" do
|
18
22
|
assert_equal 'bare', bare_tag.macro_name
|
19
23
|
end
|
@@ -121,6 +125,17 @@ class TagTest < ActiveSupport::TestCase
|
|
121
125
|
assert_equal '"<bare id=\"foo\" />"', bare_tag(:foo).compile
|
122
126
|
end
|
123
127
|
|
128
|
+
test "proc option values are evaluated in context" do
|
129
|
+
assert_equal '"<bare id=\"#{(-> { awesome }).call}\" />"', bare_tag(id: -> { awesome }).compile
|
130
|
+
end
|
131
|
+
|
132
|
+
test "markup is indented" do
|
133
|
+
ExpressTemplates::Markup::Tag.formatted do
|
134
|
+
code = ExpressTemplates.compile &-> {ul { li { "*"*36 }}}
|
135
|
+
assert_equal "<ul>\n <li>#{"*"*36}</li>\n</ul>\n", eval(code)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
124
139
|
test "print doctype for HTML5 document version" do
|
125
140
|
assert_equal '"<!DOCTYPE html>"', ExpressTemplates::Markup::Doctype.new.compile
|
126
141
|
end
|
@@ -129,6 +144,4 @@ class TagTest < ActiveSupport::TestCase
|
|
129
144
|
assert_equal '"<img>"', ExpressTemplates::Markup::Img.new.compile
|
130
145
|
end
|
131
146
|
|
132
|
-
# test "proc option values are evaluated in context"
|
133
|
-
|
134
147
|
end
|
data/test/performance_test.rb
CHANGED
@@ -80,7 +80,7 @@ HAML
|
|
80
80
|
eruby = Erubis::Eruby.new
|
81
81
|
duration_erb = time(100) { eval(eruby.convert(ERB_EXAMPLE)) }
|
82
82
|
duration_express_templates = time(100) { ExpressTemplates.render(self, "#{GARA_EXAMPLE}") }
|
83
|
-
assert_operator
|
83
|
+
assert_operator 4.0, :>, (duration_express_templates/duration_erb)
|
84
84
|
end
|
85
85
|
|
86
86
|
test "performance better than haml" do
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: express_templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Talcott Smith
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.7'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-stack_explorer
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.4'
|
111
125
|
description: Replace Erb/HAML/Slim with ExpressTemplates and write templates in a
|
112
126
|
declartive style of Ruby. With ExpressTemplates you may easily create a library
|
113
127
|
of components for use across projects.
|
@@ -125,6 +139,7 @@ files:
|
|
125
139
|
- lib/express_templates/compiler.rb
|
126
140
|
- lib/express_templates/components.rb
|
127
141
|
- lib/express_templates/components/base.rb
|
142
|
+
- lib/express_templates/components/capabilities/building.rb
|
128
143
|
- lib/express_templates/components/capabilities/conditionality.rb
|
129
144
|
- lib/express_templates/components/capabilities/configurable.rb
|
130
145
|
- lib/express_templates/components/capabilities/iterating.rb
|
@@ -135,8 +150,14 @@ files:
|
|
135
150
|
- lib/express_templates/components/column.rb
|
136
151
|
- lib/express_templates/components/container.rb
|
137
152
|
- lib/express_templates/components/content_for.rb
|
153
|
+
- lib/express_templates/components/for_each.rb
|
154
|
+
- lib/express_templates/components/form_for.rb
|
138
155
|
- lib/express_templates/components/form_rails_support.rb
|
156
|
+
- lib/express_templates/components/null_wrap.rb
|
139
157
|
- lib/express_templates/components/row.rb
|
158
|
+
- lib/express_templates/components/table_for.rb
|
159
|
+
- lib/express_templates/components/tree_for.rb
|
160
|
+
- lib/express_templates/components/unless_block.rb
|
140
161
|
- lib/express_templates/expander.rb
|
141
162
|
- lib/express_templates/indenter.rb
|
142
163
|
- lib/express_templates/macro.rb
|
@@ -158,6 +179,7 @@ files:
|
|
158
179
|
- test/components/content_for_test.rb
|
159
180
|
- test/components/iterating_test.rb
|
160
181
|
- test/components/row_test.rb
|
182
|
+
- test/components/table_for_test.rb
|
161
183
|
- test/core_extensions/proc_test.rb
|
162
184
|
- test/dummy/Rakefile
|
163
185
|
- test/dummy/app/assets/javascripts/application.js
|
@@ -217,7 +239,7 @@ files:
|
|
217
239
|
- test/expander_stack_test.rb
|
218
240
|
- test/expander_test.rb
|
219
241
|
- test/express_templates_test.rb
|
220
|
-
- test/fixtures/
|
242
|
+
- test/fixtures/a_big_page2.html
|
221
243
|
- test/handler_test.rb
|
222
244
|
- test/indenter_test.rb
|
223
245
|
- test/markup/tag_test.rb
|
@@ -259,6 +281,7 @@ test_files:
|
|
259
281
|
- test/components/content_for_test.rb
|
260
282
|
- test/components/iterating_test.rb
|
261
283
|
- test/components/row_test.rb
|
284
|
+
- test/components/table_for_test.rb
|
262
285
|
- test/core_extensions/proc_test.rb
|
263
286
|
- test/dummy/app/assets/javascripts/application.js
|
264
287
|
- test/dummy/app/assets/stylesheets/application.css
|
@@ -318,7 +341,7 @@ test_files:
|
|
318
341
|
- test/expander_stack_test.rb
|
319
342
|
- test/expander_test.rb
|
320
343
|
- test/express_templates_test.rb
|
321
|
-
- test/fixtures/
|
344
|
+
- test/fixtures/a_big_page2.html
|
322
345
|
- test/handler_test.rb
|
323
346
|
- test/indenter_test.rb
|
324
347
|
- test/markup/tag_test.rb
|