curly-templates 2.0.1 → 2.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -0
- data/README.md +85 -5
- data/curly-templates.gemspec +37 -8
- data/lib/curly.rb +1 -1
- data/lib/curly/{attribute_parser.rb → attribute_scanner.rb} +6 -4
- data/lib/curly/compiler.rb +81 -72
- data/lib/curly/component_compiler.rb +37 -31
- data/lib/curly/component_scanner.rb +19 -0
- data/lib/curly/incomplete_block_error.rb +0 -7
- data/lib/curly/incorrect_ending_error.rb +0 -21
- data/lib/curly/parser.rb +171 -0
- data/lib/curly/presenter.rb +1 -1
- data/lib/curly/scanner.rb +23 -9
- data/spec/attribute_scanner_spec.rb +46 -0
- data/spec/collection_blocks_spec.rb +88 -0
- data/spec/compiler/context_blocks_spec.rb +42 -0
- data/spec/component_compiler_spec.rb +26 -77
- data/spec/component_scanner_spec.rb +19 -0
- data/spec/{integration/components_spec.rb → components_spec.rb} +0 -0
- data/spec/{integration/conditional_blocks_spec.rb → conditional_blocks_spec.rb} +0 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/dashboards_controller.rb +13 -0
- data/spec/dummy/app/helpers/application_helper.rb +5 -0
- data/spec/dummy/app/presenters/dashboards/collection_presenter.rb +7 -0
- data/spec/dummy/app/presenters/dashboards/item_presenter.rb +7 -0
- data/spec/dummy/app/presenters/dashboards/new_presenter.rb +19 -0
- data/spec/dummy/app/presenters/dashboards/partials_presenter.rb +5 -0
- data/spec/dummy/app/presenters/dashboards/show_presenter.rb +12 -0
- data/spec/dummy/app/presenters/layouts/application_presenter.rb +9 -0
- data/spec/dummy/app/views/dashboards/_item.html.curly +1 -0
- data/spec/dummy/app/views/dashboards/collection.html.curly +5 -0
- data/spec/dummy/app/views/dashboards/new.html.curly +3 -0
- data/spec/dummy/app/views/dashboards/partials.html.curly +3 -0
- data/spec/dummy/app/views/dashboards/show.html.curly +3 -0
- data/spec/dummy/app/views/layouts/application.html.curly +8 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +12 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/integration/application_layout_spec.rb +21 -0
- data/spec/integration/collection_blocks_spec.rb +17 -78
- data/spec/integration/context_blocks_spec.rb +21 -0
- data/spec/integration/partials_spec.rb +23 -0
- data/spec/parser_spec.rb +95 -0
- data/spec/scanner_spec.rb +24 -14
- data/spec/spec_helper.rb +4 -3
- metadata +49 -14
- data/lib/curly/component_parser.rb +0 -13
- data/spec/attribute_parser_spec.rb +0 -46
- data/spec/incorrect_ending_error_spec.rb +0 -13
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'curly/attribute_parser'
|
2
|
-
|
3
|
-
module Curly
|
4
|
-
class ComponentParser
|
5
|
-
def self.parse(component)
|
6
|
-
first, rest = component.split(/\s+/, 2)
|
7
|
-
name, identifier = first.split(".", 2)
|
8
|
-
attributes = AttributeParser.parse(rest)
|
9
|
-
|
10
|
-
[name, identifier, attributes]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Curly::AttributeParser do
|
4
|
-
it "parses attributes" do
|
5
|
-
parse("width=10px height=20px").should == {
|
6
|
-
"width" => "10px",
|
7
|
-
"height" => "20px"
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
it "parses single quoted values" do
|
12
|
-
parse("title='hello world'").should == { "title" => "hello world" }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "parses double quoted values" do
|
16
|
-
parse('title="hello world"').should == { "title" => "hello world" }
|
17
|
-
end
|
18
|
-
|
19
|
-
it "parses mixed quotes" do
|
20
|
-
parse(%[x=y q="foo's bar" v='bim " bum' t="foo ' bar"]).should == {
|
21
|
-
"x" => "y",
|
22
|
-
"q" => "foo's bar",
|
23
|
-
"t" => "foo ' bar",
|
24
|
-
"v" => 'bim " bum'
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
it "deals with weird whitespace" do
|
29
|
-
parse(" size=big ").should == { "size" => "big" }
|
30
|
-
end
|
31
|
-
|
32
|
-
it "parses empty attribute lists" do
|
33
|
-
parse(nil).should == {}
|
34
|
-
parse("").should == {}
|
35
|
-
parse(" ").should == {}
|
36
|
-
end
|
37
|
-
|
38
|
-
it "fails when an invalid attribute list is passed" do
|
39
|
-
expect { parse("foo") }.to raise_exception(Curly::AttributeError)
|
40
|
-
expect { parse("foo=") }.to raise_exception(Curly::AttributeError)
|
41
|
-
end
|
42
|
-
|
43
|
-
def parse(str)
|
44
|
-
described_class.parse(str)
|
45
|
-
end
|
46
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Curly::IncorrectEndingError do
|
4
|
-
it "has a nice error message" do
|
5
|
-
error = Curly::IncorrectEndingError.new(["bar", nil], ["foo", nil])
|
6
|
-
error.message.should == "compilation error: expected `{{/foo}}`, got `{{/bar}}`"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "handles components with an identifier" do
|
10
|
-
error = Curly::IncorrectEndingError.new(["foo", "y"], ["foo", "x"])
|
11
|
-
error.message.should == "compilation error: expected `{{/foo.x}}`, got `{{/foo.y}}`"
|
12
|
-
end
|
13
|
-
end
|