twigg-app 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/_bootstrap.js +7 -0
  3. data/assets/javascripts/_jquery.js +19 -0
  4. data/assets/javascripts/_tables.js +3 -0
  5. data/assets/javascripts/_views.js +10 -0
  6. data/assets/javascripts/application.js +9 -0
  7. data/{public/application.js → assets/javascripts/views/_commit_set_bar_chart.js} +32 -34
  8. data/assets/javascripts/views/_russia.js +61 -0
  9. data/assets/javascripts/views/_tags.js +56 -0
  10. data/assets/javascripts/views/_tags_word_cloud.js +51 -0
  11. data/assets/stylesheets/_bootstrap_overrides.scss +15 -0
  12. data/assets/stylesheets/_footer.scss +28 -0
  13. data/assets/stylesheets/_global.scss +14 -0
  14. data/assets/stylesheets/_tables.scss +20 -0
  15. data/assets/stylesheets/application.scss +10 -0
  16. data/assets/stylesheets/d3/_bar_chart.scss +25 -0
  17. data/assets/stylesheets/d3/_bubble_chart.scss +22 -0
  18. data/lib/twigg-app/app/routes.rb +4 -0
  19. data/lib/twigg-app/app/server.rb +78 -21
  20. data/lib/twigg-app/app/version.rb +1 -1
  21. data/public/vendor/bootstrap/Gruntfile.js +32 -10
  22. data/public/vendor/bootstrap/README.md +2 -0
  23. data/public/vendor/bootstrap/_config.yml +5 -10
  24. data/public/vendor/bootstrap/_includes/footer.html +2 -1
  25. data/public/vendor/bootstrap/_includes/nav-components.html +33 -31
  26. data/public/vendor/bootstrap/_includes/nav-css.html +32 -22
  27. data/public/vendor/bootstrap/_includes/nav-getting-started.html +17 -1
  28. data/public/vendor/bootstrap/_includes/nav-javascript.html +1 -1
  29. data/public/vendor/bootstrap/_includes/nav-main.html +1 -1
  30. data/public/vendor/bootstrap/_includes/social-buttons.html +1 -1
  31. data/public/vendor/bootstrap/_layouts/default.html +18 -14
  32. data/public/vendor/bootstrap/_layouts/home.html +9 -6
  33. data/public/vendor/bootstrap/assets/css/docs.css +584 -396
  34. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  35. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  36. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  37. data/public/vendor/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  38. data/public/vendor/bootstrap/assets/ico/favicon.png +0 -0
  39. data/public/vendor/bootstrap/assets/js/application.js +2 -1
  40. data/public/vendor/bootstrap/assets/js/customizer.js +160 -45
  41. data/public/vendor/bootstrap/assets/js/filesaver.js +169 -0
  42. data/public/vendor/bootstrap/assets/js/jquery.js +6 -5
  43. data/public/vendor/bootstrap/assets/js/raw-files.js +3 -0
  44. data/public/vendor/bootstrap/bower.json +1 -1
  45. data/public/vendor/bootstrap/components.html +787 -364
  46. data/public/vendor/bootstrap/composer.json +1 -1
  47. data/public/vendor/bootstrap/css.html +413 -248
  48. data/public/vendor/bootstrap/customize.html +413 -447
  49. data/public/vendor/bootstrap/dist/css/bootstrap-theme.css +384 -0
  50. data/public/vendor/bootstrap/dist/css/bootstrap-theme.min.css +1 -0
  51. data/public/vendor/bootstrap/dist/css/bootstrap.css +3033 -1807
  52. data/public/vendor/bootstrap/dist/css/bootstrap.min.css +1 -1
  53. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  54. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +228 -0
  55. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  56. data/public/vendor/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  57. data/public/vendor/bootstrap/dist/js/bootstrap.js +18 -12
  58. data/public/vendor/bootstrap/dist/js/bootstrap.min.js +1 -1
  59. data/public/vendor/bootstrap/examples/carousel/carousel.css +128 -0
  60. data/public/vendor/bootstrap/examples/carousel/index.html +201 -0
  61. data/public/vendor/bootstrap/examples/grid/grid.css +28 -0
  62. data/public/vendor/bootstrap/examples/grid/index.html +119 -0
  63. data/public/vendor/bootstrap/examples/jumbotron/index.html +111 -0
  64. data/public/vendor/bootstrap/examples/jumbotron/jumbotron.css +5 -0
  65. data/public/vendor/bootstrap/examples/jumbotron-narrow/index.html +78 -0
  66. data/public/vendor/bootstrap/examples/jumbotron-narrow/jumbotron-narrow.css +79 -0
  67. data/public/vendor/bootstrap/examples/justified-nav/index.html +79 -0
  68. data/public/vendor/bootstrap/examples/justified-nav/justified-nav.css +88 -0
  69. data/public/vendor/bootstrap/examples/navbar/index.html +83 -0
  70. data/public/vendor/bootstrap/examples/navbar/navbar.css +7 -0
  71. data/public/vendor/bootstrap/examples/navbar-fixed-top/index.html +86 -0
  72. data/public/vendor/bootstrap/examples/navbar-fixed-top/navbar-fixed-top.css +4 -0
  73. data/public/vendor/bootstrap/examples/navbar-static-top/index.html +87 -0
  74. data/public/vendor/bootstrap/examples/navbar-static-top/navbar-static-top.css +7 -0
  75. data/public/vendor/bootstrap/examples/non-responsive/index.html +96 -0
  76. data/public/vendor/bootstrap/examples/non-responsive/non-responsive.css +117 -0
  77. data/public/vendor/bootstrap/examples/offcanvas/index.html +127 -0
  78. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.css +48 -0
  79. data/public/vendor/bootstrap/examples/offcanvas/offcanvas.js +5 -0
  80. data/public/vendor/bootstrap/examples/screenshots/carousel.jpg +0 -0
  81. data/public/vendor/bootstrap/examples/screenshots/grid.jpg +0 -0
  82. data/public/vendor/bootstrap/examples/screenshots/jumbotron-narrow.jpg +0 -0
  83. data/public/vendor/bootstrap/examples/screenshots/jumbotron.jpg +0 -0
  84. data/public/vendor/bootstrap/examples/screenshots/justified-nav.jpg +0 -0
  85. data/public/vendor/bootstrap/examples/screenshots/navbar-fixed.jpg +0 -0
  86. data/public/vendor/bootstrap/examples/screenshots/navbar-static.jpg +0 -0
  87. data/public/vendor/bootstrap/examples/screenshots/navbar.jpg +0 -0
  88. data/public/vendor/bootstrap/examples/screenshots/non-responsive.jpg +0 -0
  89. data/public/vendor/bootstrap/examples/screenshots/offcanvas.jpg +0 -0
  90. data/public/vendor/bootstrap/examples/screenshots/sign-in.jpg +0 -0
  91. data/public/vendor/bootstrap/examples/screenshots/starter-template.jpg +0 -0
  92. data/public/vendor/bootstrap/examples/screenshots/sticky-footer-navbar.jpg +0 -0
  93. data/public/vendor/bootstrap/examples/screenshots/sticky-footer.jpg +0 -0
  94. data/public/vendor/bootstrap/examples/screenshots/theme.jpg +0 -0
  95. data/public/vendor/bootstrap/examples/signin/index.html +46 -0
  96. data/public/vendor/bootstrap/examples/signin/signin.css +40 -0
  97. data/public/vendor/bootstrap/examples/starter-template/index.html +63 -0
  98. data/public/vendor/bootstrap/examples/starter-template/starter-template.css +7 -0
  99. data/public/vendor/bootstrap/examples/sticky-footer/index.html +51 -0
  100. data/public/vendor/bootstrap/examples/sticky-footer/sticky-footer.css +39 -0
  101. data/public/vendor/bootstrap/examples/sticky-footer-navbar/index.html +86 -0
  102. data/public/vendor/bootstrap/examples/sticky-footer-navbar/sticky-footer-navbar.css +46 -0
  103. data/public/vendor/bootstrap/examples/theme/index.html +387 -0
  104. data/public/vendor/bootstrap/examples/theme/theme.css +14 -0
  105. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  106. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +228 -0
  107. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  108. data/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  109. data/public/vendor/bootstrap/getting-started.html +513 -22
  110. data/public/vendor/bootstrap/index.html +3 -4
  111. data/public/vendor/bootstrap/javascript.html +123 -115
  112. data/public/vendor/bootstrap/js/dropdown.js +3 -3
  113. data/public/vendor/bootstrap/js/modal.js +5 -3
  114. data/public/vendor/bootstrap/js/tests/unit/modal.js +19 -0
  115. data/public/vendor/bootstrap/js/tests/vendor/jquery.js +6 -5
  116. data/public/vendor/bootstrap/js/tooltip.js +9 -5
  117. data/public/vendor/bootstrap/js/transition.js +1 -1
  118. data/public/vendor/bootstrap/less/alerts.less +7 -11
  119. data/public/vendor/bootstrap/less/bootstrap.less +17 -21
  120. data/public/vendor/bootstrap/less/button-groups.less +14 -10
  121. data/public/vendor/bootstrap/less/buttons.less +3 -2
  122. data/public/vendor/bootstrap/less/carousel.less +6 -1
  123. data/public/vendor/bootstrap/less/dropdowns.less +22 -5
  124. data/public/vendor/bootstrap/less/forms.less +36 -15
  125. data/public/vendor/bootstrap/less/glyphicons.less +232 -0
  126. data/public/vendor/bootstrap/less/grid.less +9 -3
  127. data/public/vendor/bootstrap/less/input-groups.less +1 -1
  128. data/public/vendor/bootstrap/less/jumbotron.less +16 -5
  129. data/public/vendor/bootstrap/less/labels.less +9 -5
  130. data/public/vendor/bootstrap/less/mixins.less +73 -43
  131. data/public/vendor/bootstrap/less/modals.less +8 -0
  132. data/public/vendor/bootstrap/less/navbar.less +251 -189
  133. data/public/vendor/bootstrap/less/navs.less +13 -12
  134. data/public/vendor/bootstrap/less/pager.less +1 -1
  135. data/public/vendor/bootstrap/less/pagination.less +20 -9
  136. data/public/vendor/bootstrap/less/panels.less +28 -8
  137. data/public/vendor/bootstrap/less/progress-bars.less +6 -10
  138. data/public/vendor/bootstrap/less/responsive-utilities.less +120 -49
  139. data/public/vendor/bootstrap/less/scaffolding.less +37 -18
  140. data/public/vendor/bootstrap/less/tables.less +84 -59
  141. data/public/vendor/bootstrap/less/theme.less +232 -0
  142. data/public/vendor/bootstrap/less/thumbnails.less +8 -19
  143. data/public/vendor/bootstrap/less/type.less +2 -2
  144. data/public/vendor/bootstrap/less/variables.less +63 -50
  145. data/public/vendor/bootstrap/package.json +2 -1
  146. data/public/vendor/components-backbone/LICENSE +22 -0
  147. data/public/vendor/components-backbone/README.md +10 -0
  148. data/public/vendor/components-backbone/backbone-min.js +4 -0
  149. data/public/vendor/components-backbone/backbone.js +1571 -0
  150. data/public/vendor/components-backbone/bower.json +17 -0
  151. data/public/vendor/components-backbone/component.json +21 -0
  152. data/public/vendor/components-backbone/composer.json +37 -0
  153. data/public/vendor/components-backbone/package.json +24 -0
  154. data/public/vendor/d3.layout.cloud.js +401 -0
  155. data/public/vendor/replacejs/CHANGELOG.md +4 -0
  156. data/public/vendor/replacejs/replace.js +21 -2
  157. data/public/vendor/underscore/CNAME +1 -0
  158. data/public/vendor/underscore/CONTRIBUTING.md +9 -0
  159. data/public/vendor/underscore/LICENSE +22 -0
  160. data/public/vendor/underscore/README.md +19 -0
  161. data/public/vendor/underscore/Rakefile +10 -0
  162. data/public/vendor/underscore/docs/docco.css +192 -0
  163. data/public/vendor/underscore/docs/favicon.ico +0 -0
  164. data/public/vendor/underscore/docs/images/background.png +0 -0
  165. data/public/vendor/underscore/docs/images/underscore.png +0 -0
  166. data/public/vendor/underscore/docs/underscore.html +823 -0
  167. data/public/vendor/underscore/favicon.ico +0 -0
  168. data/public/vendor/underscore/index.html +2467 -0
  169. data/public/vendor/underscore/index.js +1 -0
  170. data/public/vendor/underscore/package.json +16 -0
  171. data/public/vendor/underscore/test/arrays.js +200 -0
  172. data/public/vendor/underscore/test/chaining.js +59 -0
  173. data/public/vendor/underscore/test/collections.js +453 -0
  174. data/public/vendor/underscore/test/functions.js +265 -0
  175. data/public/vendor/underscore/test/index.html +44 -0
  176. data/public/vendor/underscore/test/objects.js +570 -0
  177. data/public/vendor/underscore/test/speed.js +75 -0
  178. data/public/vendor/underscore/test/utility.js +266 -0
  179. data/public/vendor/underscore/test/vendor/jquery.js +9404 -0
  180. data/public/vendor/underscore/test/vendor/jslitmus.js +670 -0
  181. data/public/vendor/underscore/test/vendor/qunit.css +235 -0
  182. data/public/vendor/underscore/test/vendor/qunit.js +1977 -0
  183. data/public/vendor/underscore/test/vendor/runner.js +98 -0
  184. data/public/vendor/underscore/underscore-min.js +1 -0
  185. data/public/vendor/underscore/underscore.js +1226 -0
  186. data/views/dashboard.haml +1 -1
  187. data/views/layout.haml +8 -4
  188. metadata +132 -25
  189. data/public/vendor/bootstrap/_layouts/customize.html +0 -52
  190. data/public/vendor/bootstrap/assets/js/jquery.bbq.min.js +0 -1287
  191. data/public/vendor/bootstrap-glyphicons/CHANGELOG.md +0 -3
  192. data/public/vendor/bootstrap-glyphicons/CNAME +0 -1
  193. data/public/vendor/bootstrap-glyphicons/CONTRIBUTING.md +0 -54
  194. data/public/vendor/bootstrap-glyphicons/LICENSE +0 -19
  195. data/public/vendor/bootstrap-glyphicons/README.md +0 -61
  196. data/public/vendor/bootstrap-glyphicons/_config.yml +0 -12
  197. data/public/vendor/bootstrap-glyphicons/composer.json +0 -9
  198. data/public/vendor/bootstrap-glyphicons/css/bootstrap-glyphicons.css +0 -2
  199. data/public/vendor/bootstrap-glyphicons/css/bootstrap.css +0 -9
  200. data/public/vendor/bootstrap-glyphicons/css/docs.css +0 -160
  201. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.eot +0 -0
  202. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.otf +0 -0
  203. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.svg +0 -175
  204. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.ttf +0 -0
  205. data/public/vendor/bootstrap-glyphicons/fonts/glyphiconshalflings-regular.woff +0 -0
  206. data/public/vendor/bootstrap-glyphicons/index.html +0 -255
  207. data/public/vendor/bootstrap-glyphicons/less/bootstrap-glyphicons.less +0 -201
  208. data/public/vendor/bootstrap-glyphicons/package.json +0 -18
@@ -0,0 +1,266 @@
1
+ $(document).ready(function() {
2
+
3
+ var templateSettings;
4
+
5
+ module("Utility", {
6
+
7
+ setup: function() {
8
+ templateSettings = _.clone(_.templateSettings);
9
+ },
10
+
11
+ teardown: function() {
12
+ _.templateSettings = templateSettings;
13
+ }
14
+
15
+ });
16
+
17
+ test("#750 - Return _ instance.", 2, function() {
18
+ var instance = _([]);
19
+ ok(_(instance) === instance);
20
+ ok(new _(instance) === instance);
21
+ });
22
+
23
+ test("identity", function() {
24
+ var moe = {name : 'moe'};
25
+ equal(_.identity(moe), moe, 'moe is the same as his identity');
26
+ });
27
+
28
+ test("random", function() {
29
+ var array = _.range(1000);
30
+ var min = Math.pow(2, 31);
31
+ var max = Math.pow(2, 62);
32
+
33
+ ok(_.every(array, function() {
34
+ return _.random(min, max) >= min;
35
+ }), "should produce a random number greater than or equal to the minimum number");
36
+
37
+ ok(_.some(array, function() {
38
+ return _.random(Number.MAX_VALUE) > 0;
39
+ }), "should produce a random number when passed `Number.MAX_VALUE`");
40
+ });
41
+
42
+ test("uniqueId", function() {
43
+ var ids = [], i = 0;
44
+ while(i++ < 100) ids.push(_.uniqueId());
45
+ equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids');
46
+ });
47
+
48
+ test("times", function() {
49
+ var vals = [];
50
+ _.times(3, function (i) { vals.push(i); });
51
+ ok(_.isEqual(vals, [0,1,2]), "is 0 indexed");
52
+ //
53
+ vals = [];
54
+ _(3).times(function(i) { vals.push(i); });
55
+ ok(_.isEqual(vals, [0,1,2]), "works as a wrapper");
56
+ // collects return values
57
+ ok(_.isEqual([0, 1, 2], _.times(3, function(i) { return i; })), "collects return values");
58
+ });
59
+
60
+ test("mixin", function() {
61
+ _.mixin({
62
+ myReverse: function(string) {
63
+ return string.split('').reverse().join('');
64
+ }
65
+ });
66
+ equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _');
67
+ equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
68
+ });
69
+
70
+ test("_.escape", function() {
71
+ equal(_.escape("Curly & Moe"), "Curly &amp; Moe");
72
+ equal(_.escape("Curly &amp; Moe"), "Curly &amp;amp; Moe");
73
+ equal(_.escape(null), '');
74
+ });
75
+
76
+ test("_.unescape", function() {
77
+ var string = "Curly & Moe";
78
+ equal(_.unescape("Curly &amp; Moe"), string);
79
+ equal(_.unescape("Curly &amp;amp; Moe"), "Curly &amp; Moe");
80
+ equal(_.unescape(null), '');
81
+ equal(_.unescape(_.escape(string)), string);
82
+ });
83
+
84
+ test("template", function() {
85
+ var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
86
+ var result = basicTemplate({thing : 'This'});
87
+ equal(result, "This is gettin' on my noives!", 'can do basic attribute interpolation');
88
+
89
+ var sansSemicolonTemplate = _.template("A <% this %> B");
90
+ equal(sansSemicolonTemplate(), "A B");
91
+
92
+ var backslashTemplate = _.template("<%= thing %> is \\ridanculous");
93
+ equal(backslashTemplate({thing: 'This'}), "This is \\ridanculous");
94
+
95
+ var escapeTemplate = _.template('<%= a ? "checked=\\"checked\\"" : "" %>');
96
+ equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.');
97
+
98
+ var fancyTemplate = _.template("<ul><% \
99
+ for (var key in people) { \
100
+ %><li><%= people[key] %></li><% } %></ul>");
101
+ result = fancyTemplate({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
102
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
103
+
104
+ var escapedCharsInJavascriptTemplate = _.template("<ul><% _.each(numbers.split('\\n'), function(item) { %><li><%= item %></li><% }) %></ul>");
105
+ result = escapedCharsInJavascriptTemplate({numbers: "one\ntwo\nthree\nfour"});
106
+ equal(result, "<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>", 'Can use escaped characters (e.g. \\n) in Javascript');
107
+
108
+ var namespaceCollisionTemplate = _.template("<%= pageCount %> <%= thumbnails[pageCount] %> <% _.each(thumbnails, function(p) { %><div class=\"thumbnail\" rel=\"<%= p %>\"></div><% }); %>");
109
+ result = namespaceCollisionTemplate({
110
+ pageCount: 3,
111
+ thumbnails: {
112
+ 1: "p1-thumbnail.gif",
113
+ 2: "p2-thumbnail.gif",
114
+ 3: "p3-thumbnail.gif"
115
+ }
116
+ });
117
+ equal(result, "3 p3-thumbnail.gif <div class=\"thumbnail\" rel=\"p1-thumbnail.gif\"></div><div class=\"thumbnail\" rel=\"p2-thumbnail.gif\"></div><div class=\"thumbnail\" rel=\"p3-thumbnail.gif\"></div>");
118
+
119
+ var noInterpolateTemplate = _.template("<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>");
120
+ result = noInterpolateTemplate();
121
+ equal(result, "<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>");
122
+
123
+ var quoteTemplate = _.template("It's its, not it's");
124
+ equal(quoteTemplate({}), "It's its, not it's");
125
+
126
+ var quoteInStatementAndBody = _.template("<%\
127
+ if(foo == 'bar'){ \
128
+ %>Statement quotes and 'quotes'.<% } %>");
129
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
130
+
131
+ var withNewlinesAndTabs = _.template('This\n\t\tis: <%= x %>.\n\tok.\nend.');
132
+ equal(withNewlinesAndTabs({x: 'that'}), 'This\n\t\tis: that.\n\tok.\nend.');
133
+
134
+ var template = _.template("<i><%- value %></i>");
135
+ var result = template({value: "<script>"});
136
+ equal(result, '<i>&lt;script&gt;</i>');
137
+
138
+ var stooge = {
139
+ name: "Moe",
140
+ template: _.template("I'm <%= this.name %>")
141
+ };
142
+ equal(stooge.template(), "I'm Moe");
143
+
144
+ if (!$.browser.msie) {
145
+ var fromHTML = _.template($('#template').html());
146
+ equal(fromHTML({data : 12345}).replace(/\s/g, ''), '<li>24690</li>');
147
+ }
148
+
149
+ _.templateSettings = {
150
+ evaluate : /\{\{([\s\S]+?)\}\}/g,
151
+ interpolate : /\{\{=([\s\S]+?)\}\}/g
152
+ };
153
+
154
+ var custom = _.template("<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>");
155
+ result = custom({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
156
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
157
+
158
+ var customQuote = _.template("It's its, not it's");
159
+ equal(customQuote({}), "It's its, not it's");
160
+
161
+ var quoteInStatementAndBody = _.template("{{ if(foo == 'bar'){ }}Statement quotes and 'quotes'.{{ } }}");
162
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
163
+
164
+ _.templateSettings = {
165
+ evaluate : /<\?([\s\S]+?)\?>/g,
166
+ interpolate : /<\?=([\s\S]+?)\?>/g
167
+ };
168
+
169
+ var customWithSpecialChars = _.template("<ul><? for (var key in people) { ?><li><?= people[key] ?></li><? } ?></ul>");
170
+ result = customWithSpecialChars({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
171
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
172
+
173
+ var customWithSpecialCharsQuote = _.template("It's its, not it's");
174
+ equal(customWithSpecialCharsQuote({}), "It's its, not it's");
175
+
176
+ var quoteInStatementAndBody = _.template("<? if(foo == 'bar'){ ?>Statement quotes and 'quotes'.<? } ?>");
177
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
178
+
179
+ _.templateSettings = {
180
+ interpolate : /\{\{(.+?)\}\}/g
181
+ };
182
+
183
+ var mustache = _.template("Hello {{planet}}!");
184
+ equal(mustache({planet : "World"}), "Hello World!", "can mimic mustache.js");
185
+
186
+ var templateWithNull = _.template("a null undefined {{planet}}");
187
+ equal(templateWithNull({planet : "world"}), "a null undefined world", "can handle missing escape and evaluate settings");
188
+ });
189
+
190
+ test('_.template provides the generated function source, when a SyntaxError occurs', function() {
191
+ try {
192
+ _.template('<b><%= if x %></b>');
193
+ } catch (ex) {
194
+ var source = ex.source;
195
+ }
196
+ ok(/__p/.test(source));
197
+ });
198
+
199
+ test('_.template handles \\u2028 & \\u2029', function() {
200
+ var tmpl = _.template('<p>\u2028<%= "\\u2028\\u2029" %>\u2029</p>');
201
+ strictEqual(tmpl(), '<p>\u2028\u2028\u2029\u2029</p>');
202
+ });
203
+
204
+ test('result calls functions and returns primitives', function() {
205
+ var obj = {w: '', x: 'x', y: function(){ return this.x; }};
206
+ strictEqual(_.result(obj, 'w'), '');
207
+ strictEqual(_.result(obj, 'x'), 'x');
208
+ strictEqual(_.result(obj, 'y'), 'x');
209
+ strictEqual(_.result(obj, 'z'), undefined);
210
+ strictEqual(_.result(null, 'x'), null);
211
+ });
212
+
213
+ test('_.templateSettings.variable', function() {
214
+ var s = '<%=data.x%>';
215
+ var data = {x: 'x'};
216
+ strictEqual(_.template(s, data, {variable: 'data'}), 'x');
217
+ _.templateSettings.variable = 'data';
218
+ strictEqual(_.template(s)(data), 'x');
219
+ });
220
+
221
+ test('#547 - _.templateSettings is unchanged by custom settings.', function() {
222
+ ok(!_.templateSettings.variable);
223
+ _.template('', {}, {variable: 'x'});
224
+ ok(!_.templateSettings.variable);
225
+ });
226
+
227
+ test('#556 - undefined template variables.', function() {
228
+ var template = _.template('<%=x%>');
229
+ strictEqual(template({x: null}), '');
230
+ strictEqual(template({x: undefined}), '');
231
+
232
+ var templateEscaped = _.template('<%-x%>');
233
+ strictEqual(templateEscaped({x: null}), '');
234
+ strictEqual(templateEscaped({x: undefined}), '');
235
+
236
+ var templateWithProperty = _.template('<%=x.foo%>');
237
+ strictEqual(templateWithProperty({x: {} }), '');
238
+ strictEqual(templateWithProperty({x: {} }), '');
239
+
240
+ var templateWithPropertyEscaped = _.template('<%-x.foo%>');
241
+ strictEqual(templateWithPropertyEscaped({x: {} }), '');
242
+ strictEqual(templateWithPropertyEscaped({x: {} }), '');
243
+ });
244
+
245
+ test('interpolate evaluates code only once.', 2, function() {
246
+ var count = 0;
247
+ var template = _.template('<%= f() %>');
248
+ template({f: function(){ ok(!(count++)); }});
249
+
250
+ var countEscaped = 0;
251
+ var templateEscaped = _.template('<%- f() %>');
252
+ templateEscaped({f: function(){ ok(!(countEscaped++)); }});
253
+ });
254
+
255
+ test('#746 - _.template settings are not modified.', 1, function() {
256
+ var settings = {};
257
+ _.template('', null, settings);
258
+ deepEqual(settings, {});
259
+ });
260
+
261
+ test('#779 - delimeters are applied to unescaped text.', 1, function() {
262
+ var template = _.template('<<\nx\n>>', null, {evaluate: /<<(.*?)>>/g});
263
+ strictEqual(template(), '<<\nx\n>>');
264
+ });
265
+
266
+ });