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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile +2 -0
  4. data/README.md +85 -5
  5. data/curly-templates.gemspec +37 -8
  6. data/lib/curly.rb +1 -1
  7. data/lib/curly/{attribute_parser.rb → attribute_scanner.rb} +6 -4
  8. data/lib/curly/compiler.rb +81 -72
  9. data/lib/curly/component_compiler.rb +37 -31
  10. data/lib/curly/component_scanner.rb +19 -0
  11. data/lib/curly/incomplete_block_error.rb +0 -7
  12. data/lib/curly/incorrect_ending_error.rb +0 -21
  13. data/lib/curly/parser.rb +171 -0
  14. data/lib/curly/presenter.rb +1 -1
  15. data/lib/curly/scanner.rb +23 -9
  16. data/spec/attribute_scanner_spec.rb +46 -0
  17. data/spec/collection_blocks_spec.rb +88 -0
  18. data/spec/compiler/context_blocks_spec.rb +42 -0
  19. data/spec/component_compiler_spec.rb +26 -77
  20. data/spec/component_scanner_spec.rb +19 -0
  21. data/spec/{integration/components_spec.rb → components_spec.rb} +0 -0
  22. data/spec/{integration/conditional_blocks_spec.rb → conditional_blocks_spec.rb} +0 -0
  23. data/spec/dummy/.gitignore +1 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  25. data/spec/dummy/app/controllers/dashboards_controller.rb +13 -0
  26. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  27. data/spec/dummy/app/presenters/dashboards/collection_presenter.rb +7 -0
  28. data/spec/dummy/app/presenters/dashboards/item_presenter.rb +7 -0
  29. data/spec/dummy/app/presenters/dashboards/new_presenter.rb +19 -0
  30. data/spec/dummy/app/presenters/dashboards/partials_presenter.rb +5 -0
  31. data/spec/dummy/app/presenters/dashboards/show_presenter.rb +12 -0
  32. data/spec/dummy/app/presenters/layouts/application_presenter.rb +9 -0
  33. data/spec/dummy/app/views/dashboards/_item.html.curly +1 -0
  34. data/spec/dummy/app/views/dashboards/collection.html.curly +5 -0
  35. data/spec/dummy/app/views/dashboards/new.html.curly +3 -0
  36. data/spec/dummy/app/views/dashboards/partials.html.curly +3 -0
  37. data/spec/dummy/app/views/dashboards/show.html.curly +3 -0
  38. data/spec/dummy/app/views/layouts/application.html.curly +8 -0
  39. data/spec/dummy/config.ru +4 -0
  40. data/spec/dummy/config/application.rb +12 -0
  41. data/spec/dummy/config/boot.rb +5 -0
  42. data/spec/dummy/config/environment.rb +5 -0
  43. data/spec/dummy/config/environments/test.rb +36 -0
  44. data/spec/dummy/config/routes.rb +6 -0
  45. data/spec/integration/application_layout_spec.rb +21 -0
  46. data/spec/integration/collection_blocks_spec.rb +17 -78
  47. data/spec/integration/context_blocks_spec.rb +21 -0
  48. data/spec/integration/partials_spec.rb +23 -0
  49. data/spec/parser_spec.rb +95 -0
  50. data/spec/scanner_spec.rb +24 -14
  51. data/spec/spec_helper.rb +4 -3
  52. metadata +49 -14
  53. data/lib/curly/component_parser.rb +0 -13
  54. data/spec/attribute_parser_spec.rb +0 -46
  55. 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