handlebars 0.0.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +1 -1
  2. data/.gitmodules +3 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +1 -1
  5. data/README.mdown +44 -0
  6. data/Rakefile +3 -0
  7. data/handlebars.gemspec +19 -13
  8. data/lib/handlebars.rb +4 -3
  9. data/lib/handlebars/context.rb +37 -0
  10. data/lib/handlebars/version.rb +1 -1
  11. data/spec/handlebars_spec.rb +40 -0
  12. data/spike.rb +17 -0
  13. data/vendor/handlebars/.gitignore +6 -0
  14. data/vendor/handlebars/.jshintrc +50 -0
  15. data/vendor/handlebars/.npmignore +11 -0
  16. data/vendor/handlebars/Gemfile +5 -0
  17. data/vendor/handlebars/LICENSE +20 -0
  18. data/vendor/handlebars/README.markdown +315 -0
  19. data/vendor/handlebars/Rakefile +116 -0
  20. data/vendor/handlebars/bench/benchwarmer.js +149 -0
  21. data/vendor/handlebars/bench/handlebars.js +163 -0
  22. data/vendor/handlebars/bin/handlebars +139 -0
  23. data/vendor/handlebars/lib/handlebars.js +14 -0
  24. data/vendor/handlebars/lib/handlebars/base.js +101 -0
  25. data/vendor/handlebars/lib/handlebars/compiler/ast.js +103 -0
  26. data/vendor/handlebars/lib/handlebars/compiler/base.js +27 -0
  27. data/vendor/handlebars/lib/handlebars/compiler/compiler.js +808 -0
  28. data/vendor/handlebars/lib/handlebars/compiler/index.js +7 -0
  29. data/vendor/handlebars/lib/handlebars/compiler/printer.js +137 -0
  30. data/vendor/handlebars/lib/handlebars/compiler/visitor.js +13 -0
  31. data/vendor/handlebars/lib/handlebars/runtime.js +68 -0
  32. data/vendor/handlebars/lib/handlebars/utils.js +68 -0
  33. data/vendor/handlebars/package.json +25 -0
  34. data/vendor/handlebars/spec/acceptance_spec.rb +101 -0
  35. data/vendor/handlebars/spec/parser_spec.rb +264 -0
  36. data/vendor/handlebars/spec/qunit_spec.js +1067 -0
  37. data/vendor/handlebars/spec/spec_helper.rb +157 -0
  38. data/vendor/handlebars/spec/tokenizer_spec.rb +254 -0
  39. data/vendor/handlebars/src/handlebars.l +42 -0
  40. data/vendor/handlebars/src/handlebars.yy +99 -0
  41. metadata +93 -77
  42. data/README.md +0 -39
  43. data/lib/handlebars/generator.rb +0 -4
  44. data/lib/handlebars/parser.rb +0 -240
  45. data/spec/generator_spec.rb +0 -5
  46. data/spec/parser_spec.rb +0 -163
  47. data/spec/spec_helper.rb +0 -17
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
- require 'handlebars'
3
-
4
- describe Handlebars::Generator do
5
- end
data/spec/parser_spec.rb DELETED
@@ -1,163 +0,0 @@
1
- require 'spec_helper'
2
- require 'handlebars'
3
-
4
- describe Handlebars::Parser do
5
-
6
- it 'fails when the handlebars inverted section syntax is used without an opened section' do
7
- lexer = Handlebars::Parser.new
8
- proc {
9
- lexer.compile(<<-EOF)
10
- {{^}}
11
- <h1>No projects</h1>
12
- {{/project}}
13
- EOF
14
- }.should raise_error(Handlebars::Parser::SyntaxError)
15
- end
16
-
17
- it 'parses the handlebars inverted section syntax' do
18
- lexer = Handlebars::Parser.new
19
- tokens = lexer.compile(<<-EOF)
20
- {{#project}}
21
- <h1>{{name}}</h1>
22
- <div>{{body}}</div>
23
- {{^}}
24
- <h1>No projects</h1>
25
- {{/project}}
26
- EOF
27
- expected = [:multi,
28
- [:mustache, :section, "project", nil, [:multi,
29
- [:static, "<h1>"],
30
- [:mustache, :etag, "name", nil],
31
- [:static, "</h1>\n<div>"],
32
- [:mustache, :etag, "body", nil],
33
- [:static, "</div>\n"]]],
34
- [:mustache, :inverted_section, "project", [:multi,
35
- [:static, "<h1>No projects</h1>\n"]]]]
36
- tokens.should eq(expected)
37
- end
38
-
39
- it 'parses the mustache inverted section syntax' do
40
- lexer = Handlebars::Parser.new
41
- tokens = lexer.compile(<<-EOF)
42
- {{#project}}
43
- <h1>{{name}}</h1>
44
- <div>{{body}}</div>
45
- {{/project}}
46
- {{^project}}
47
- <h1>No projects</h1>
48
- {{/project}}
49
- EOF
50
- expected = [:multi,
51
- [:mustache, :section, "project", nil, [:multi,
52
- [:static, "<h1>"],
53
- [:mustache, :etag, "name", nil],
54
- [:static, "</h1>\n<div>"],
55
- [:mustache, :etag, "body", nil],
56
- [:static, "</div>\n"]]],
57
- [:mustache, :inverted_section, "project", [:multi,
58
- [:static, "<h1>No projects</h1>\n"]]]]
59
- tokens.should eq(expected)
60
- end
61
-
62
- it 'parses helpers with context paths' do
63
- lexer = Handlebars::Parser.new
64
- tokens = lexer.compile(<<-EOF)
65
- <h1>{{helper context}}</h1>
66
- <h1>{{helper ..}}</h1>
67
- {{#items ..}}
68
- haha
69
- {{haha}}
70
- {{/items}}
71
- EOF
72
-
73
- expected = [:multi,
74
- [:static, "<h1>"],
75
- [:mustache, :etag, "helper", "context"],
76
- [:static, "</h1>\n<h1>"],
77
- [:mustache, :etag, "helper", ".."],
78
- [:static, "</h1>\n"],
79
- [:mustache, :section, "items", "..", [:multi,
80
- [:static, "haha\n"],
81
- [:mustache, :etag, "haha", nil],
82
- [:static, "\n"]]]]
83
- tokens.should eq(expected)
84
- end
85
-
86
- it 'parses extended paths' do
87
- lexer = Handlebars::Parser.new
88
- tokens = lexer.compile(<<-EOF)
89
- <h1>{{../../header}}</h1>
90
- <div>{{./header}}
91
- {{hans/hubert/header}}</div>
92
- {{#ines/ingrid/items}}
93
- a
94
- {{/ines/ingrid/items}}
95
- EOF
96
-
97
- expected = [:multi,
98
- [:static, "<h1>"],
99
- [:mustache, :etag, "../../header", nil],
100
- [:static, "</h1>\n<div>"],
101
- [:mustache, :etag, "./header", nil],
102
- [:static, "\n"],
103
- [:mustache, :etag, "hans/hubert/header", nil],
104
- [:static, "</div>\n"],
105
- [:mustache, :section, "ines/ingrid/items", nil, [:multi,
106
- [:static, "a\n"]]]]
107
- tokens.should eq(expected)
108
- end
109
-
110
- it 'parses the mustache example' do
111
- lexer = Handlebars::Parser.new
112
- tokens = lexer.compile(<<-EOF)
113
- <h1>{{header}}</h1>
114
- {{#items}}
115
- {{#first}}
116
- <li><strong>{{name}}</strong></li>
117
- {{/first}}
118
- {{#link}}
119
- <li><a href="{{url}}">{{name}}</a></li>
120
- {{/link}}
121
- {{/items}}
122
-
123
- {{#empty}}
124
- <p>The list is empty.</p>
125
- {{/empty}}
126
- EOF
127
-
128
- expected = [:multi,
129
- [:static, "<h1>"],
130
- [:mustache, :etag, "header", nil],
131
- [:static, "</h1>\n"],
132
- [:mustache,
133
- :section,
134
- "items",
135
- nil,
136
- [:multi,
137
- [:mustache,
138
- :section,
139
- "first",
140
- nil,
141
- [:multi,
142
- [:static, "<li><strong>"],
143
- [:mustache, :etag, "name", nil],
144
- [:static, "</strong></li>\n"]]],
145
- [:mustache,
146
- :section,
147
- "link",
148
- nil,
149
- [:multi,
150
- [:static, "<li><a href=\""],
151
- [:mustache, :etag, "url", nil],
152
- [:static, "\">"],
153
- [:mustache, :etag, "name", nil],
154
- [:static, "</a></li>\n"]]]]],
155
- [:mustache,
156
- :section,
157
- "empty",
158
- nil,
159
- [:multi, [:static, "<p>The list is empty.</p>\n"]]]]
160
-
161
- tokens.should eq(expected)
162
- end
163
- end
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'rspec'
2
-
3
- # Requires supporting files with custom matchers and macros, etc,
4
- # in ./support/ and its subdirectories.
5
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
-
7
- RSpec.configure do |config|
8
- # == Mock Framework
9
- #
10
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
11
- #
12
- # config.mock_with :mocha
13
- # config.mock_with :flexmock
14
- # config.mock_with :rr
15
- config.mock_with :rspec
16
- end
17
-