sass-twitter-bootstrap 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +14 -0
  4. data/LICENSE +176 -0
  5. data/Makefile +94 -0
  6. data/README.md +217 -0
  7. data/Rakefile +52 -0
  8. data/bootstrap-2.0.4.css +4661 -0
  9. data/bootstrap-2.0.4.min.css +9 -0
  10. data/bootstrap-responsive-2.0.4.css +932 -0
  11. data/bootstrap-responsive-2.0.4.min.css +9 -0
  12. data/docs/assets/css/bootstrap-responsive.css +932 -0
  13. data/docs/assets/css/bootstrap.css +4661 -0
  14. data/docs/assets/css/docs.css +846 -0
  15. data/docs/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  16. data/docs/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  17. data/docs/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  18. data/docs/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  19. data/docs/assets/ico/favicon.ico +0 -0
  20. data/docs/assets/img/bird.png +0 -0
  21. data/docs/assets/img/bootstrap-mdo-sfmoma-01.jpg +0 -0
  22. data/docs/assets/img/bootstrap-mdo-sfmoma-02.jpg +0 -0
  23. data/docs/assets/img/bootstrap-mdo-sfmoma-03.jpg +0 -0
  24. data/docs/assets/img/browsers.png +0 -0
  25. data/docs/assets/img/example-sites/fleetio.png +0 -0
  26. data/docs/assets/img/example-sites/jshint.png +0 -0
  27. data/docs/assets/img/example-sites/kippt.png +0 -0
  28. data/docs/assets/img/example-sites/soundready.png +0 -0
  29. data/docs/assets/img/examples/bootstrap-example-fluid.jpg +0 -0
  30. data/docs/assets/img/examples/bootstrap-example-hero.jpg +0 -0
  31. data/docs/assets/img/examples/bootstrap-example-starter.jpg +0 -0
  32. data/docs/assets/img/github-16px.png +0 -0
  33. data/docs/assets/img/glyphicons-halflings-white.png +0 -0
  34. data/docs/assets/img/glyphicons-halflings.png +0 -0
  35. data/docs/assets/img/glyphicons/glyphicons_009_magic.png +0 -0
  36. data/docs/assets/img/glyphicons/glyphicons_042_group.png +0 -0
  37. data/docs/assets/img/glyphicons/glyphicons_079_podium.png +0 -0
  38. data/docs/assets/img/glyphicons/glyphicons_082_roundabout.png +0 -0
  39. data/docs/assets/img/glyphicons/glyphicons_155_show_thumbnails.png +0 -0
  40. data/docs/assets/img/glyphicons/glyphicons_163_iphone.png +0 -0
  41. data/docs/assets/img/glyphicons/glyphicons_214_resize_small.png +0 -0
  42. data/docs/assets/img/glyphicons/glyphicons_266_book_open.png +0 -0
  43. data/docs/assets/img/grid-18px-masked.png +0 -0
  44. data/docs/assets/img/icon-css3.png +0 -0
  45. data/docs/assets/img/icon-github.png +0 -0
  46. data/docs/assets/img/icon-html5.png +0 -0
  47. data/docs/assets/img/icon-twitter.png +0 -0
  48. data/docs/assets/img/less-logo-large.png +0 -0
  49. data/docs/assets/img/less-small.png +0 -0
  50. data/docs/assets/img/responsive-illustrations.png +0 -0
  51. data/docs/assets/js/README.md +106 -0
  52. data/docs/assets/js/application.js +184 -0
  53. data/docs/assets/js/bootstrap-alert.js +90 -0
  54. data/docs/assets/js/bootstrap-button.js +96 -0
  55. data/docs/assets/js/bootstrap-carousel.js +169 -0
  56. data/docs/assets/js/bootstrap-collapse.js +157 -0
  57. data/docs/assets/js/bootstrap-dropdown.js +100 -0
  58. data/docs/assets/js/bootstrap-modal.js +218 -0
  59. data/docs/assets/js/bootstrap-popover.js +98 -0
  60. data/docs/assets/js/bootstrap-scrollspy.js +151 -0
  61. data/docs/assets/js/bootstrap-tab.js +135 -0
  62. data/docs/assets/js/bootstrap-tooltip.js +275 -0
  63. data/docs/assets/js/bootstrap-transition.js +61 -0
  64. data/docs/assets/js/bootstrap-typeahead.js +285 -0
  65. data/docs/assets/js/bootstrap.js +1825 -0
  66. data/docs/assets/js/bootstrap.min.js +6 -0
  67. data/docs/assets/js/google-code-prettify/prettify.css +30 -0
  68. data/docs/assets/js/google-code-prettify/prettify.js +28 -0
  69. data/docs/assets/js/jquery.js +9252 -0
  70. data/docs/base-css.html +1710 -0
  71. data/docs/build/index.js +44 -0
  72. data/docs/build/node_modules/.bin/hulk +93 -0
  73. data/docs/build/node_modules/hogan.js/.git_ignore +1 -0
  74. data/docs/build/node_modules/hogan.js/.gitmodules +3 -0
  75. data/docs/build/node_modules/hogan.js/LICENSE +177 -0
  76. data/docs/build/node_modules/hogan.js/Makefile +62 -0
  77. data/docs/build/node_modules/hogan.js/README.md +93 -0
  78. data/docs/build/node_modules/hogan.js/bin/hulk +93 -0
  79. data/docs/build/node_modules/hogan.js/lib/compiler.js +348 -0
  80. data/docs/build/node_modules/hogan.js/lib/hogan.js +20 -0
  81. data/docs/build/node_modules/hogan.js/lib/template.js +233 -0
  82. data/docs/build/node_modules/hogan.js/package.json +20 -0
  83. data/docs/build/node_modules/hogan.js/test/html/list.html +8 -0
  84. data/docs/build/node_modules/hogan.js/test/index.html +13 -0
  85. data/docs/build/node_modules/hogan.js/test/index.js +848 -0
  86. data/docs/build/node_modules/hogan.js/test/mustache.js +90 -0
  87. data/docs/build/node_modules/hogan.js/test/spec.js +77 -0
  88. data/docs/build/node_modules/hogan.js/test/spec/Changes +31 -0
  89. data/docs/build/node_modules/hogan.js/test/spec/README.md +65 -0
  90. data/docs/build/node_modules/hogan.js/test/spec/Rakefile +27 -0
  91. data/docs/build/node_modules/hogan.js/test/spec/TESTING.md +46 -0
  92. data/docs/build/node_modules/hogan.js/test/spec/specs/comments.json +1 -0
  93. data/docs/build/node_modules/hogan.js/test/spec/specs/comments.yml +103 -0
  94. data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.json +1 -0
  95. data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.yml +158 -0
  96. data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.json +1 -0
  97. data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.yml +230 -0
  98. data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.json +1 -0
  99. data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.yml +193 -0
  100. data/docs/build/node_modules/hogan.js/test/spec/specs/partials.json +1 -0
  101. data/docs/build/node_modules/hogan.js/test/spec/specs/partials.yml +109 -0
  102. data/docs/build/node_modules/hogan.js/test/spec/specs/sections.json +1 -0
  103. data/docs/build/node_modules/hogan.js/test/spec/specs/sections.yml +256 -0
  104. data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.json +1 -0
  105. data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.yml +149 -0
  106. data/docs/build/node_modules/hogan.js/test/templates/list.mustache +8 -0
  107. data/docs/build/node_modules/hogan.js/tools/release.js +74 -0
  108. data/docs/build/node_modules/hogan.js/tools/web_templates.js +32 -0
  109. data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.js +500 -0
  110. data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.min.js +14 -0
  111. data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.js +500 -0
  112. data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.min.js +14 -0
  113. data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.js +545 -0
  114. data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.min.js +5 -0
  115. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.amd.js +576 -0
  116. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.common.js +576 -0
  117. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.js +572 -0
  118. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.amd.js +5 -0
  119. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.common.js +5 -0
  120. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.js +5 -0
  121. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.mustache.js +5 -0
  122. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.mustache.js +619 -0
  123. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.js +233 -0
  124. data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.min.js +5 -0
  125. data/docs/build/node_modules/hogan.js/web/favicon.ico +0 -0
  126. data/docs/build/node_modules/hogan.js/web/images/logo.png +0 -0
  127. data/docs/build/node_modules/hogan.js/web/images/noise.png +0 -0
  128. data/docs/build/node_modules/hogan.js/web/images/small-hogan-icon.png +0 -0
  129. data/docs/build/node_modules/hogan.js/web/images/stripes.png +0 -0
  130. data/docs/build/node_modules/hogan.js/web/index.html.mustache +139 -0
  131. data/docs/build/node_modules/hogan.js/web/stylesheets/layout.css +206 -0
  132. data/docs/build/node_modules/hogan.js/web/stylesheets/skeleton.css +236 -0
  133. data/docs/build/node_modules/hogan.js/wrappers/amd.js.mustache +21 -0
  134. data/docs/build/node_modules/hogan.js/wrappers/common.js.mustache +21 -0
  135. data/docs/build/node_modules/hogan.js/wrappers/js.mustache +17 -0
  136. data/docs/build/node_modules/hogan.js/wrappers/mustache.js.mustache +64 -0
  137. data/docs/build/package.json +6 -0
  138. data/docs/components.html +1931 -0
  139. data/docs/download.html +454 -0
  140. data/docs/examples.html +147 -0
  141. data/docs/examples/fluid.html +162 -0
  142. data/docs/examples/hero.html +109 -0
  143. data/docs/examples/starter-template.html +79 -0
  144. data/docs/index.html +259 -0
  145. data/docs/javascript.html +1520 -0
  146. data/docs/less.html +1060 -0
  147. data/docs/scaffolding.html +671 -0
  148. data/docs/templates/layout.mustache +146 -0
  149. data/docs/templates/pages/base-css.mustache +1594 -0
  150. data/docs/templates/pages/components.mustache +1815 -0
  151. data/docs/templates/pages/download.mustache +338 -0
  152. data/docs/templates/pages/examples.mustache +31 -0
  153. data/docs/templates/pages/index.mustache +144 -0
  154. data/docs/templates/pages/javascript.mustache +1405 -0
  155. data/docs/templates/pages/less.mustache +944 -0
  156. data/docs/templates/pages/scaffolding.mustache +555 -0
  157. data/docs/templates/pages/upgrading.mustache +194 -0
  158. data/docs/upgrading.html +310 -0
  159. data/js/tests/index.html +54 -0
  160. data/js/tests/phantom.js +63 -0
  161. data/js/tests/server.js +14 -0
  162. data/js/tests/unit/bootstrap-alert.js +56 -0
  163. data/js/tests/unit/bootstrap-button.js +77 -0
  164. data/js/tests/unit/bootstrap-carousel.js +28 -0
  165. data/js/tests/unit/bootstrap-collapse.js +54 -0
  166. data/js/tests/unit/bootstrap-dropdown.js +87 -0
  167. data/js/tests/unit/bootstrap-modal.js +114 -0
  168. data/js/tests/unit/bootstrap-phantom.js +21 -0
  169. data/js/tests/unit/bootstrap-popover.js +93 -0
  170. data/js/tests/unit/bootstrap-scrollspy.js +31 -0
  171. data/js/tests/unit/bootstrap-tab.js +61 -0
  172. data/js/tests/unit/bootstrap-tooltip.js +155 -0
  173. data/js/tests/unit/bootstrap-transition.js +13 -0
  174. data/js/tests/unit/bootstrap-typeahead.js +148 -0
  175. data/js/tests/vendor/jquery.js +9252 -0
  176. data/js/tests/vendor/qunit.css +232 -0
  177. data/js/tests/vendor/qunit.js +1510 -0
  178. data/lib/sass-twitter-bootstrap.rb +9 -0
  179. data/lib/sass/twitter/bootstrap/rails.rb +14 -0
  180. data/lib/sass/twitter/bootstrap/version.rb +7 -0
  181. data/package.json +25 -0
  182. data/sass-twitter-bootstrap.gemspec +19 -0
  183. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  184. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  185. data/vendor/assets/javascripts/README.md +112 -0
  186. data/vendor/assets/javascripts/twitter/bootstrap-alert.js +90 -0
  187. data/vendor/assets/javascripts/twitter/bootstrap-button.js +96 -0
  188. data/vendor/assets/javascripts/twitter/bootstrap-carousel.js +169 -0
  189. data/vendor/assets/javascripts/twitter/bootstrap-collapse.js +157 -0
  190. data/vendor/assets/javascripts/twitter/bootstrap-dropdown.js +100 -0
  191. data/vendor/assets/javascripts/twitter/bootstrap-modal.js +218 -0
  192. data/vendor/assets/javascripts/twitter/bootstrap-popover.js +98 -0
  193. data/vendor/assets/javascripts/twitter/bootstrap-scrollspy.js +151 -0
  194. data/vendor/assets/javascripts/twitter/bootstrap-tab.js +135 -0
  195. data/vendor/assets/javascripts/twitter/bootstrap-tooltip.js +275 -0
  196. data/vendor/assets/javascripts/twitter/bootstrap-transition.js +61 -0
  197. data/vendor/assets/javascripts/twitter/bootstrap-typeahead.js +285 -0
  198. data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
  199. data/vendor/assets/stylesheets/tests/css-tests.css +52 -0
  200. data/vendor/assets/stylesheets/tests/css-tests.html +917 -0
  201. data/vendor/assets/stylesheets/tests/forms.html +179 -0
  202. data/vendor/assets/stylesheets/tests/navbar.html +108 -0
  203. data/vendor/assets/stylesheets/twitter/_accordion.scss +33 -0
  204. data/vendor/assets/stylesheets/twitter/_alerts.scss +58 -0
  205. data/vendor/assets/stylesheets/twitter/_breadcrumbs.scss +24 -0
  206. data/vendor/assets/stylesheets/twitter/_button-groups.scss +191 -0
  207. data/vendor/assets/stylesheets/twitter/_buttons.scss +191 -0
  208. data/vendor/assets/stylesheets/twitter/_carousel.scss +121 -0
  209. data/vendor/assets/stylesheets/twitter/_close.scss +29 -0
  210. data/vendor/assets/stylesheets/twitter/_code.scss +57 -0
  211. data/vendor/assets/stylesheets/twitter/_component-animations.scss +20 -0
  212. data/vendor/assets/stylesheets/twitter/_dropdowns.scss +143 -0
  213. data/vendor/assets/stylesheets/twitter/_forms.scss +582 -0
  214. data/vendor/assets/stylesheets/twitter/_grid.scss +5 -0
  215. data/vendor/assets/stylesheets/twitter/_hero-unit.scss +22 -0
  216. data/vendor/assets/stylesheets/twitter/_labels-badges.scss +52 -0
  217. data/vendor/assets/stylesheets/twitter/_layouts.scss +17 -0
  218. data/vendor/assets/stylesheets/twitter/_mixins.scss +643 -0
  219. data/vendor/assets/stylesheets/twitter/_modals.scss +90 -0
  220. data/vendor/assets/stylesheets/twitter/_navbar.scss +358 -0
  221. data/vendor/assets/stylesheets/twitter/_navs.scss +363 -0
  222. data/vendor/assets/stylesheets/twitter/_pager.scss +36 -0
  223. data/vendor/assets/stylesheets/twitter/_pagination.scss +56 -0
  224. data/vendor/assets/stylesheets/twitter/_popovers.scss +49 -0
  225. data/vendor/assets/stylesheets/twitter/_progress-bars.scss +117 -0
  226. data/vendor/assets/stylesheets/twitter/_reset.scss +131 -0
  227. data/vendor/assets/stylesheets/twitter/_responsive-1200px-min.scss +26 -0
  228. data/vendor/assets/stylesheets/twitter/_responsive-767px-max.scss +149 -0
  229. data/vendor/assets/stylesheets/twitter/_responsive-768px-979px.scss +17 -0
  230. data/vendor/assets/stylesheets/twitter/_responsive-navbar.scss +153 -0
  231. data/vendor/assets/stylesheets/twitter/_responsive-utilities.scss +41 -0
  232. data/vendor/assets/stylesheets/twitter/_scaffolding.scss +29 -0
  233. data/vendor/assets/stylesheets/twitter/_sprites.scss +191 -0
  234. data/vendor/assets/stylesheets/twitter/_tables.scss +155 -0
  235. data/vendor/assets/stylesheets/twitter/_thumbnails.scss +47 -0
  236. data/vendor/assets/stylesheets/twitter/_tooltip.scss +35 -0
  237. data/vendor/assets/stylesheets/twitter/_type.scss +232 -0
  238. data/vendor/assets/stylesheets/twitter/_utilities.scss +23 -0
  239. data/vendor/assets/stylesheets/twitter/_variables.scss +204 -0
  240. data/vendor/assets/stylesheets/twitter/_wells.scss +27 -0
  241. data/vendor/assets/stylesheets/twitter/bootstrap.scss +62 -0
  242. data/vendor/assets/stylesheets/twitter/responsive.scss +48 -0
  243. metadata +304 -0
@@ -0,0 +1 @@
1
+ {"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Partial tags are used to expand an external template into the current\ntemplate.\n\nThe tag's content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter.\n\nThis tag's content names the partial to inject. Set Delimiter tags MUST NOT\naffect the parsing of a partial. The partial MUST be rendered against the\ncontext stack local to the tag. If the named partial cannot be found, the\nempty string SHOULD be used instead, as in interpolations.\n\nPartial tags SHOULD be treated as standalone when appropriate. If this tag\nis used standalone, any whitespace preceding the tag should treated as\nindentation, and prepended to each line of the partial before rendering.\n","tests":[{"name":"Basic Behavior","data":{},"expected":"\"from partial\"","template":"\"{{>text}}\"","desc":"The greater-than operator should expand to the named partial.","partials":{"text":"from partial"}},{"name":"Failed Lookup","data":{},"expected":"\"\"","template":"\"{{>text}}\"","desc":"The empty string should be used when the named partial is not found.","partials":{}},{"name":"Context","data":{"text":"content"},"expected":"\"*content*\"","template":"\"{{>partial}}\"","desc":"The greater-than operator should operate within the current context.","partials":{"partial":"*{{text}}*"}},{"name":"Recursion","data":{"content":"X","nodes":[{"content":"Y","nodes":[]}]},"expected":"X<Y<>>","template":"{{>node}}","desc":"The greater-than operator should properly recurse.","partials":{"node":"{{content}}<{{#nodes}}{{>node}}{{/nodes}}>"}},{"name":"Surrounding Whitespace","data":{},"expected":"| \t|\t |","template":"| {{>partial}} |","desc":"The greater-than operator should not alter surrounding whitespace.","partials":{"partial":"\t|\t"}},{"name":"Inline Indentation","data":{"data":"|"},"expected":" | >\n>\n","template":" {{data}} {{> partial}}\n","desc":"Whitespace should be left untouched.","partials":{"partial":">\n>"}},{"name":"Standalone Line Endings","data":{},"expected":"|\r\n>|","template":"|\r\n{{>partial}}\r\n|","desc":"\"\\r\\n\" should be considered a newline for standalone tags.","partials":{"partial":">"}},{"name":"Standalone Without Previous Line","data":{},"expected":" >\n >>","template":" {{>partial}}\n>","desc":"Standalone tags should not require a newline to precede them.","partials":{"partial":">\n>"}},{"name":"Standalone Without Newline","data":{},"expected":">\n >\n >","template":">\n {{>partial}}","desc":"Standalone tags should not require a newline to follow them.","partials":{"partial":">\n>"}},{"name":"Standalone Indentation","data":{"content":"<\n->"},"expected":"\\\n |\n <\n->\n |\n/\n","template":"\\\n {{>partial}}\n/\n","desc":"Each line of the partial should be indented before rendering.","partials":{"partial":"|\n{{{content}}}\n|\n"}},{"name":"Padding Whitespace","data":{"boolean":true},"expected":"|[]|","template":"|{{> partial }}|","desc":"Superfluous in-tag whitespace should be ignored.","partials":{"partial":"[]"}}]}
@@ -0,0 +1,109 @@
1
+ overview: |
2
+ Partial tags are used to expand an external template into the current
3
+ template.
4
+
5
+ The tag's content MUST be a non-whitespace character sequence NOT containing
6
+ the current closing delimiter.
7
+
8
+ This tag's content names the partial to inject. Set Delimiter tags MUST NOT
9
+ affect the parsing of a partial. The partial MUST be rendered against the
10
+ context stack local to the tag. If the named partial cannot be found, the
11
+ empty string SHOULD be used instead, as in interpolations.
12
+
13
+ Partial tags SHOULD be treated as standalone when appropriate. If this tag
14
+ is used standalone, any whitespace preceding the tag should treated as
15
+ indentation, and prepended to each line of the partial before rendering.
16
+ tests:
17
+ - name: Basic Behavior
18
+ desc: The greater-than operator should expand to the named partial.
19
+ data: { }
20
+ template: '"{{>text}}"'
21
+ partials: { text: 'from partial' }
22
+ expected: '"from partial"'
23
+
24
+ - name: Failed Lookup
25
+ desc: The empty string should be used when the named partial is not found.
26
+ data: { }
27
+ template: '"{{>text}}"'
28
+ partials: { }
29
+ expected: '""'
30
+
31
+ - name: Context
32
+ desc: The greater-than operator should operate within the current context.
33
+ data: { text: 'content' }
34
+ template: '"{{>partial}}"'
35
+ partials: { partial: '*{{text}}*' }
36
+ expected: '"*content*"'
37
+
38
+ - name: Recursion
39
+ desc: The greater-than operator should properly recurse.
40
+ data: { content: "X", nodes: [ { content: "Y", nodes: [] } ] }
41
+ template: '{{>node}}'
42
+ partials: { node: '{{content}}<{{#nodes}}{{>node}}{{/nodes}}>' }
43
+ expected: 'X<Y<>>'
44
+
45
+ # Whitespace Sensitivity
46
+
47
+ - name: Surrounding Whitespace
48
+ desc: The greater-than operator should not alter surrounding whitespace.
49
+ data: { }
50
+ template: '| {{>partial}} |'
51
+ partials: { partial: "\t|\t" }
52
+ expected: "| \t|\t |"
53
+
54
+ - name: Inline Indentation
55
+ desc: Whitespace should be left untouched.
56
+ data: { data: '|' }
57
+ template: " {{data}} {{> partial}}\n"
58
+ partials: { partial: ">\n>" }
59
+ expected: " | >\n>\n"
60
+
61
+ - name: Standalone Line Endings
62
+ desc: '"\r\n" should be considered a newline for standalone tags.'
63
+ data: { }
64
+ template: "|\r\n{{>partial}}\r\n|"
65
+ partials: { partial: ">" }
66
+ expected: "|\r\n>|"
67
+
68
+ - name: Standalone Without Previous Line
69
+ desc: Standalone tags should not require a newline to precede them.
70
+ data: { }
71
+ template: " {{>partial}}\n>"
72
+ partials: { partial: ">\n>"}
73
+ expected: " >\n >>"
74
+
75
+ - name: Standalone Without Newline
76
+ desc: Standalone tags should not require a newline to follow them.
77
+ data: { }
78
+ template: ">\n {{>partial}}"
79
+ partials: { partial: ">\n>" }
80
+ expected: ">\n >\n >"
81
+
82
+ - name: Standalone Indentation
83
+ desc: Each line of the partial should be indented before rendering.
84
+ data: { content: "<\n->" }
85
+ template: |
86
+ \
87
+ {{>partial}}
88
+ /
89
+ partials:
90
+ partial: |
91
+ |
92
+ {{{content}}}
93
+ |
94
+ expected: |
95
+ \
96
+ |
97
+ <
98
+ ->
99
+ |
100
+ /
101
+
102
+ # Whitespace Insensitivity
103
+
104
+ - name: Padding Whitespace
105
+ desc: Superfluous in-tag whitespace should be ignored.
106
+ data: { boolean: true }
107
+ template: "|{{> partial }}|"
108
+ partials: { partial: "[]" }
109
+ expected: '|[]|'
@@ -0,0 +1 @@
1
+ {"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Section tags and End Section tags are used in combination to wrap a section\nof the template for iteration\n\nThese tags' content MUST be a non-whitespace character sequence NOT\ncontaining the current closing delimiter; each Section tag MUST be followed\nby an End Section tag with the same content within the same section.\n\nThis tag's content names the data to replace the tag. Name resolution is as\nfollows:\n 1) Split the name on periods; the first part is the name to resolve, any\n remaining parts should be retained.\n 2) Walk the context stack from top to bottom, finding the first context\n that is a) a hash containing the name as a key OR b) an object responding\n to a method with the given name.\n 3) If the context is a hash, the data is the value associated with the\n name.\n 4) If the context is an object and the method with the given name has an\n arity of 1, the method SHOULD be called with a String containing the\n unprocessed contents of the sections; the data is the value returned.\n 5) Otherwise, the data is the value returned by calling the method with\n the given name.\n 6) If any name parts were retained in step 1, each should be resolved\n against a context stack containing only the result from the former\n resolution. If any part fails resolution, the result should be considered\n falsey, and should interpolate as the empty string.\nIf the data is not of a list type, it is coerced into a list as follows: if\nthe data is truthy (e.g. `!!data == true`), use a single-element list\ncontaining the data, otherwise use an empty list.\n\nFor each element in the data list, the element MUST be pushed onto the\ncontext stack, the section MUST be rendered, and the element MUST be popped\noff the context stack.\n\nSection and End Section tags SHOULD be treated as standalone when\nappropriate.\n","tests":[{"name":"Truthy","data":{"boolean":true},"expected":"\"This should be rendered.\"","template":"\"{{#boolean}}This should be rendered.{{/boolean}}\"","desc":"Truthy sections should have their contents rendered."},{"name":"Falsey","data":{"boolean":false},"expected":"\"\"","template":"\"{{#boolean}}This should not be rendered.{{/boolean}}\"","desc":"Falsey sections should have their contents omitted."},{"name":"Context","data":{"context":{"name":"Joe"}},"expected":"\"Hi Joe.\"","template":"\"{{#context}}Hi {{name}}.{{/context}}\"","desc":"Objects and hashes should be pushed onto the context stack."},{"name":"Deeply Nested Contexts","data":{"a":{"one":1},"b":{"two":2},"c":{"three":3},"d":{"four":4},"e":{"five":5}},"expected":"1\n121\n12321\n1234321\n123454321\n1234321\n12321\n121\n1\n","template":"{{#a}}\n{{one}}\n{{#b}}\n{{one}}{{two}}{{one}}\n{{#c}}\n{{one}}{{two}}{{three}}{{two}}{{one}}\n{{#d}}\n{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}\n{{#e}}\n{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}\n{{/e}}\n{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}\n{{/d}}\n{{one}}{{two}}{{three}}{{two}}{{one}}\n{{/c}}\n{{one}}{{two}}{{one}}\n{{/b}}\n{{one}}\n{{/a}}\n","desc":"All elements on the context stack should be accessible."},{"name":"List","data":{"list":[{"item":1},{"item":2},{"item":3}]},"expected":"\"123\"","template":"\"{{#list}}{{item}}{{/list}}\"","desc":"Lists should be iterated; list items should visit the context stack."},{"name":"Empty List","data":{"list":[]},"expected":"\"\"","template":"\"{{#list}}Yay lists!{{/list}}\"","desc":"Empty lists should behave like falsey values."},{"name":"Doubled","data":{"two":"second","bool":true},"expected":"* first\n* second\n* third\n","template":"{{#bool}}\n* first\n{{/bool}}\n* {{two}}\n{{#bool}}\n* third\n{{/bool}}\n","desc":"Multiple sections per template should be permitted."},{"name":"Nested (Truthy)","data":{"bool":true},"expected":"| A B C D E |","template":"| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |","desc":"Nested truthy sections should have their contents rendered."},{"name":"Nested (Falsey)","data":{"bool":false},"expected":"| A E |","template":"| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |","desc":"Nested falsey sections should be omitted."},{"name":"Context Misses","data":{},"expected":"[]","template":"[{{#missing}}Found key 'missing'!{{/missing}}]","desc":"Failed context lookups should be considered falsey."},{"name":"Implicit Iterator - String","data":{"list":["a","b","c","d","e"]},"expected":"\"(a)(b)(c)(d)(e)\"","template":"\"{{#list}}({{.}}){{/list}}\"","desc":"Implicit iterators should directly interpolate strings."},{"name":"Implicit Iterator - Integer","data":{"list":[1,2,3,4,5]},"expected":"\"(1)(2)(3)(4)(5)\"","template":"\"{{#list}}({{.}}){{/list}}\"","desc":"Implicit iterators should cast integers to strings and interpolate."},{"name":"Implicit Iterator - Decimal","data":{"list":[1.1,2.2,3.3,4.4,5.5]},"expected":"\"(1.1)(2.2)(3.3)(4.4)(5.5)\"","template":"\"{{#list}}({{.}}){{/list}}\"","desc":"Implicit iterators should cast decimals to strings and interpolate."},{"name":"Dotted Names - Truthy","data":{"a":{"b":{"c":true}}},"expected":"\"Here\" == \"Here\"","template":"\"{{#a.b.c}}Here{{/a.b.c}}\" == \"Here\"","desc":"Dotted names should be valid for Section tags."},{"name":"Dotted Names - Falsey","data":{"a":{"b":{"c":false}}},"expected":"\"\" == \"\"","template":"\"{{#a.b.c}}Here{{/a.b.c}}\" == \"\"","desc":"Dotted names should be valid for Section tags."},{"name":"Dotted Names - Broken Chains","data":{"a":{}},"expected":"\"\" == \"\"","template":"\"{{#a.b.c}}Here{{/a.b.c}}\" == \"\"","desc":"Dotted names that cannot be resolved should be considered falsey."},{"name":"Surrounding Whitespace","data":{"boolean":true},"expected":" | \t|\t | \n","template":" | {{#boolean}}\t|\t{{/boolean}} | \n","desc":"Sections should not alter surrounding whitespace."},{"name":"Internal Whitespace","data":{"boolean":true},"expected":" | \n | \n","template":" | {{#boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n","desc":"Sections should not alter internal whitespace."},{"name":"Indented Inline Sections","data":{"boolean":true},"expected":" YES\n GOOD\n","template":" {{#boolean}}YES{{/boolean}}\n {{#boolean}}GOOD{{/boolean}}\n","desc":"Single-line sections should not alter surrounding whitespace."},{"name":"Standalone Lines","data":{"boolean":true},"expected":"| This Is\n|\n| A Line\n","template":"| This Is\n{{#boolean}}\n|\n{{/boolean}}\n| A Line\n","desc":"Standalone lines should be removed from the template."},{"name":"Indented Standalone Lines","data":{"boolean":true},"expected":"| This Is\n|\n| A Line\n","template":"| This Is\n {{#boolean}}\n|\n {{/boolean}}\n| A Line\n","desc":"Indented standalone lines should be removed from the template."},{"name":"Standalone Line Endings","data":{"boolean":true},"expected":"|\r\n|","template":"|\r\n{{#boolean}}\r\n{{/boolean}}\r\n|","desc":"\"\\r\\n\" should be considered a newline for standalone tags."},{"name":"Standalone Without Previous Line","data":{"boolean":true},"expected":"#\n/","template":" {{#boolean}}\n#{{/boolean}}\n/","desc":"Standalone tags should not require a newline to precede them."},{"name":"Standalone Without Newline","data":{"boolean":true},"expected":"#\n/\n","template":"#{{#boolean}}\n/\n {{/boolean}}","desc":"Standalone tags should not require a newline to follow them."},{"name":"Padding","data":{"boolean":true},"expected":"|=|","template":"|{{# boolean }}={{/ boolean }}|","desc":"Superfluous in-tag whitespace should be ignored."}]}
@@ -0,0 +1,256 @@
1
+ overview: |
2
+ Section tags and End Section tags are used in combination to wrap a section
3
+ of the template for iteration
4
+
5
+ These tags' content MUST be a non-whitespace character sequence NOT
6
+ containing the current closing delimiter; each Section tag MUST be followed
7
+ by an End Section tag with the same content within the same section.
8
+
9
+ This tag's content names the data to replace the tag. Name resolution is as
10
+ follows:
11
+ 1) Split the name on periods; the first part is the name to resolve, any
12
+ remaining parts should be retained.
13
+ 2) Walk the context stack from top to bottom, finding the first context
14
+ that is a) a hash containing the name as a key OR b) an object responding
15
+ to a method with the given name.
16
+ 3) If the context is a hash, the data is the value associated with the
17
+ name.
18
+ 4) If the context is an object and the method with the given name has an
19
+ arity of 1, the method SHOULD be called with a String containing the
20
+ unprocessed contents of the sections; the data is the value returned.
21
+ 5) Otherwise, the data is the value returned by calling the method with
22
+ the given name.
23
+ 6) If any name parts were retained in step 1, each should be resolved
24
+ against a context stack containing only the result from the former
25
+ resolution. If any part fails resolution, the result should be considered
26
+ falsey, and should interpolate as the empty string.
27
+ If the data is not of a list type, it is coerced into a list as follows: if
28
+ the data is truthy (e.g. `!!data == true`), use a single-element list
29
+ containing the data, otherwise use an empty list.
30
+
31
+ For each element in the data list, the element MUST be pushed onto the
32
+ context stack, the section MUST be rendered, and the element MUST be popped
33
+ off the context stack.
34
+
35
+ Section and End Section tags SHOULD be treated as standalone when
36
+ appropriate.
37
+ tests:
38
+ - name: Truthy
39
+ desc: Truthy sections should have their contents rendered.
40
+ data: { boolean: true }
41
+ template: '"{{#boolean}}This should be rendered.{{/boolean}}"'
42
+ expected: '"This should be rendered."'
43
+
44
+ - name: Falsey
45
+ desc: Falsey sections should have their contents omitted.
46
+ data: { boolean: false }
47
+ template: '"{{#boolean}}This should not be rendered.{{/boolean}}"'
48
+ expected: '""'
49
+
50
+ - name: Context
51
+ desc: Objects and hashes should be pushed onto the context stack.
52
+ data: { context: { name: 'Joe' } }
53
+ template: '"{{#context}}Hi {{name}}.{{/context}}"'
54
+ expected: '"Hi Joe."'
55
+
56
+ - name: Deeply Nested Contexts
57
+ desc: All elements on the context stack should be accessible.
58
+ data:
59
+ a: { one: 1 }
60
+ b: { two: 2 }
61
+ c: { three: 3 }
62
+ d: { four: 4 }
63
+ e: { five: 5 }
64
+ template: |
65
+ {{#a}}
66
+ {{one}}
67
+ {{#b}}
68
+ {{one}}{{two}}{{one}}
69
+ {{#c}}
70
+ {{one}}{{two}}{{three}}{{two}}{{one}}
71
+ {{#d}}
72
+ {{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
73
+ {{#e}}
74
+ {{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
75
+ {{/e}}
76
+ {{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
77
+ {{/d}}
78
+ {{one}}{{two}}{{three}}{{two}}{{one}}
79
+ {{/c}}
80
+ {{one}}{{two}}{{one}}
81
+ {{/b}}
82
+ {{one}}
83
+ {{/a}}
84
+ expected: |
85
+ 1
86
+ 121
87
+ 12321
88
+ 1234321
89
+ 123454321
90
+ 1234321
91
+ 12321
92
+ 121
93
+ 1
94
+
95
+ - name: List
96
+ desc: Lists should be iterated; list items should visit the context stack.
97
+ data: { list: [ { item: 1 }, { item: 2 }, { item: 3 } ] }
98
+ template: '"{{#list}}{{item}}{{/list}}"'
99
+ expected: '"123"'
100
+
101
+ - name: Empty List
102
+ desc: Empty lists should behave like falsey values.
103
+ data: { list: [ ] }
104
+ template: '"{{#list}}Yay lists!{{/list}}"'
105
+ expected: '""'
106
+
107
+ - name: Doubled
108
+ desc: Multiple sections per template should be permitted.
109
+ data: { bool: true, two: 'second' }
110
+ template: |
111
+ {{#bool}}
112
+ * first
113
+ {{/bool}}
114
+ * {{two}}
115
+ {{#bool}}
116
+ * third
117
+ {{/bool}}
118
+ expected: |
119
+ * first
120
+ * second
121
+ * third
122
+
123
+ - name: Nested (Truthy)
124
+ desc: Nested truthy sections should have their contents rendered.
125
+ data: { bool: true }
126
+ template: "| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |"
127
+ expected: "| A B C D E |"
128
+
129
+ - name: Nested (Falsey)
130
+ desc: Nested falsey sections should be omitted.
131
+ data: { bool: false }
132
+ template: "| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |"
133
+ expected: "| A E |"
134
+
135
+ - name: Context Misses
136
+ desc: Failed context lookups should be considered falsey.
137
+ data: { }
138
+ template: "[{{#missing}}Found key 'missing'!{{/missing}}]"
139
+ expected: "[]"
140
+
141
+ # Implicit Iterators
142
+
143
+ - name: Implicit Iterator - String
144
+ desc: Implicit iterators should directly interpolate strings.
145
+ data:
146
+ list: [ 'a', 'b', 'c', 'd', 'e' ]
147
+ template: '"{{#list}}({{.}}){{/list}}"'
148
+ expected: '"(a)(b)(c)(d)(e)"'
149
+
150
+ - name: Implicit Iterator - Integer
151
+ desc: Implicit iterators should cast integers to strings and interpolate.
152
+ data:
153
+ list: [ 1, 2, 3, 4, 5 ]
154
+ template: '"{{#list}}({{.}}){{/list}}"'
155
+ expected: '"(1)(2)(3)(4)(5)"'
156
+
157
+ - name: Implicit Iterator - Decimal
158
+ desc: Implicit iterators should cast decimals to strings and interpolate.
159
+ data:
160
+ list: [ 1.10, 2.20, 3.30, 4.40, 5.50 ]
161
+ template: '"{{#list}}({{.}}){{/list}}"'
162
+ expected: '"(1.1)(2.2)(3.3)(4.4)(5.5)"'
163
+
164
+ # Dotted Names
165
+
166
+ - name: Dotted Names - Truthy
167
+ desc: Dotted names should be valid for Section tags.
168
+ data: { a: { b: { c: true } } }
169
+ template: '"{{#a.b.c}}Here{{/a.b.c}}" == "Here"'
170
+ expected: '"Here" == "Here"'
171
+
172
+ - name: Dotted Names - Falsey
173
+ desc: Dotted names should be valid for Section tags.
174
+ data: { a: { b: { c: false } } }
175
+ template: '"{{#a.b.c}}Here{{/a.b.c}}" == ""'
176
+ expected: '"" == ""'
177
+
178
+ - name: Dotted Names - Broken Chains
179
+ desc: Dotted names that cannot be resolved should be considered falsey.
180
+ data: { a: { } }
181
+ template: '"{{#a.b.c}}Here{{/a.b.c}}" == ""'
182
+ expected: '"" == ""'
183
+
184
+ # Whitespace Sensitivity
185
+
186
+ - name: Surrounding Whitespace
187
+ desc: Sections should not alter surrounding whitespace.
188
+ data: { boolean: true }
189
+ template: " | {{#boolean}}\t|\t{{/boolean}} | \n"
190
+ expected: " | \t|\t | \n"
191
+
192
+ - name: Internal Whitespace
193
+ desc: Sections should not alter internal whitespace.
194
+ data: { boolean: true }
195
+ template: " | {{#boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n"
196
+ expected: " | \n | \n"
197
+
198
+ - name: Indented Inline Sections
199
+ desc: Single-line sections should not alter surrounding whitespace.
200
+ data: { boolean: true }
201
+ template: " {{#boolean}}YES{{/boolean}}\n {{#boolean}}GOOD{{/boolean}}\n"
202
+ expected: " YES\n GOOD\n"
203
+
204
+ - name: Standalone Lines
205
+ desc: Standalone lines should be removed from the template.
206
+ data: { boolean: true }
207
+ template: |
208
+ | This Is
209
+ {{#boolean}}
210
+ |
211
+ {{/boolean}}
212
+ | A Line
213
+ expected: |
214
+ | This Is
215
+ |
216
+ | A Line
217
+
218
+ - name: Indented Standalone Lines
219
+ desc: Indented standalone lines should be removed from the template.
220
+ data: { boolean: true }
221
+ template: |
222
+ | This Is
223
+ {{#boolean}}
224
+ |
225
+ {{/boolean}}
226
+ | A Line
227
+ expected: |
228
+ | This Is
229
+ |
230
+ | A Line
231
+
232
+ - name: Standalone Line Endings
233
+ desc: '"\r\n" should be considered a newline for standalone tags.'
234
+ data: { boolean: true }
235
+ template: "|\r\n{{#boolean}}\r\n{{/boolean}}\r\n|"
236
+ expected: "|\r\n|"
237
+
238
+ - name: Standalone Without Previous Line
239
+ desc: Standalone tags should not require a newline to precede them.
240
+ data: { boolean: true }
241
+ template: " {{#boolean}}\n#{{/boolean}}\n/"
242
+ expected: "#\n/"
243
+
244
+ - name: Standalone Without Newline
245
+ desc: Standalone tags should not require a newline to follow them.
246
+ data: { boolean: true }
247
+ template: "#{{#boolean}}\n/\n {{/boolean}}"
248
+ expected: "#\n/\n"
249
+
250
+ # Whitespace Insensitivity
251
+
252
+ - name: Padding
253
+ desc: Superfluous in-tag whitespace should be ignored.
254
+ data: { boolean: true }
255
+ template: '|{{# boolean }}={{/ boolean }}|'
256
+ expected: '|=|'
@@ -0,0 +1 @@
1
+ {"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Lambdas are a special-cased data type for use in interpolations and\nsections.\n\nWhen used as the data value for an Interpolation tag, the lambda MUST be\ntreatable as an arity 0 function, and invoked as such. The returned value\nMUST be rendered against the default delimiters, then interpolated in place\nof the lambda.\n\nWhen used as the data value for a Section tag, the lambda MUST be treatable\nas an arity 1 function, and invoked as such (passing a String containing the\nunprocessed section contents). The returned value MUST be rendered against\nthe current delimiters, then interpolated in place of the section.\n","tests":[{"name":"Interpolation","data":{"lambda":{"php":"return \"world\";","clojure":"(fn [] \"world\")","__tag__":"code","perl":"sub { \"world\" }","python":"lambda: \"world\"","ruby":"proc { \"world\" }","js":"function() { return \"world\" }"}},"expected":"Hello, world!","template":"Hello, {{lambda}}!","desc":"A lambda's return value should be interpolated."},{"name":"Interpolation - Expansion","data":{"planet":"world","lambda":{"php":"return \"{{planet}}\";","clojure":"(fn [] \"{{planet}}\")","__tag__":"code","perl":"sub { \"{{planet}}\" }","python":"lambda: \"{{planet}}\"","ruby":"proc { \"{{planet}}\" }","js":"function() { return \"{{planet}}\" }"}},"expected":"Hello, world!","template":"Hello, {{lambda}}!","desc":"A lambda's return value should be parsed."},{"name":"Interpolation - Alternate Delimiters","data":{"planet":"world","lambda":{"php":"return \"|planet| => {{planet}}\";","clojure":"(fn [] \"|planet| => {{planet}}\")","__tag__":"code","perl":"sub { \"|planet| => {{planet}}\" }","python":"lambda: \"|planet| => {{planet}}\"","ruby":"proc { \"|planet| => {{planet}}\" }","js":"function() { return \"|planet| => {{planet}}\" }"}},"expected":"Hello, (|planet| => world)!","template":"{{= | | =}}\nHello, (|&lambda|)!","desc":"A lambda's return value should parse with the default delimiters."},{"name":"Interpolation - Multiple Calls","data":{"lambda":{"php":"global $calls; return ++$calls;","clojure":"(def g (atom 0)) (fn [] (swap! g inc))","__tag__":"code","perl":"sub { no strict; $calls += 1 }","python":"lambda: globals().update(calls=globals().get(\"calls\",0)+1) or calls","ruby":"proc { $calls ||= 0; $calls += 1 }","js":"function() { return (g=(function(){return this})()).calls=(g.calls||0)+1 }"}},"expected":"1 == 2 == 3","template":"{{lambda}} == {{{lambda}}} == {{lambda}}","desc":"Interpolated lambdas should not be cached."},{"name":"Escaping","data":{"lambda":{"php":"return \">\";","clojure":"(fn [] \">\")","__tag__":"code","perl":"sub { \">\" }","python":"lambda: \">\"","ruby":"proc { \">\" }","js":"function() { return \">\" }"}},"expected":"<&gt;>","template":"<{{lambda}}{{{lambda}}}","desc":"Lambda results should be appropriately escaped."},{"name":"Section","data":{"x":"Error!","lambda":{"php":"return ($text == \"{{x}}\") ? \"yes\" : \"no\";","clojure":"(fn [text] (if (= text \"{{x}}\") \"yes\" \"no\"))","__tag__":"code","perl":"sub { $_[0] eq \"{{x}}\" ? \"yes\" : \"no\" }","python":"lambda text: text == \"{{x}}\" and \"yes\" or \"no\"","ruby":"proc { |text| text == \"{{x}}\" ? \"yes\" : \"no\" }","js":"function(txt) { return (txt == \"{{x}}\" ? \"yes\" : \"no\") }"}},"expected":"<yes>","template":"<{{#lambda}}{{x}}{{/lambda}}>","desc":"Lambdas used for sections should receive the raw section string."},{"name":"Section - Expansion","data":{"planet":"Earth","lambda":{"php":"return $text . \"{{planet}}\" . $text;","clojure":"(fn [text] (str text \"{{planet}}\" text))","__tag__":"code","perl":"sub { $_[0] . \"{{planet}}\" . $_[0] }","python":"lambda text: \"%s{{planet}}%s\" % (text, text)","ruby":"proc { |text| \"#{text}{{planet}}#{text}\" }","js":"function(txt) { return txt + \"{{planet}}\" + txt }"}},"expected":"<-Earth->","template":"<{{#lambda}}-{{/lambda}}>","desc":"Lambdas used for sections should have their results parsed."},{"name":"Section - Alternate Delimiters","data":{"planet":"Earth","lambda":{"php":"return $text . \"{{planet}} => |planet|\" . $text;","clojure":"(fn [text] (str text \"{{planet}} => |planet|\" text))","__tag__":"code","perl":"sub { $_[0] . \"{{planet}} => |planet|\" . $_[0] }","python":"lambda text: \"%s{{planet}} => |planet|%s\" % (text, text)","ruby":"proc { |text| \"#{text}{{planet}} => |planet|#{text}\" }","js":"function(txt) { return txt + \"{{planet}} => |planet|\" + txt }"}},"expected":"<-{{planet}} => Earth->","template":"{{= | | =}}<|#lambda|-|/lambda|>","desc":"Lambdas used for sections should parse with the current delimiters."},{"name":"Section - Multiple Calls","data":{"lambda":{"php":"return \"__\" . $text . \"__\";","clojure":"(fn [text] (str \"__\" text \"__\"))","__tag__":"code","perl":"sub { \"__\" . $_[0] . \"__\" }","python":"lambda text: \"__%s__\" % (text)","ruby":"proc { |text| \"__#{text}__\" }","js":"function(txt) { return \"__\" + txt + \"__\" }"}},"expected":"__FILE__ != __LINE__","template":"{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}","desc":"Lambdas used for sections should not be cached."},{"name":"Inverted Section","data":{"static":"static","lambda":{"php":"return false;","clojure":"(fn [text] false)","__tag__":"code","perl":"sub { 0 }","python":"lambda text: 0","ruby":"proc { |text| false }","js":"function(txt) { return false }"}},"expected":"<>","template":"<{{^lambda}}{{static}}{{/lambda}}>","desc":"Lambdas used for inverted sections should be considered truthy."}]}
@@ -0,0 +1,149 @@
1
+ overview: |
2
+ Lambdas are a special-cased data type for use in interpolations and
3
+ sections.
4
+
5
+ When used as the data value for an Interpolation tag, the lambda MUST be
6
+ treatable as an arity 0 function, and invoked as such. The returned value
7
+ MUST be rendered against the default delimiters, then interpolated in place
8
+ of the lambda.
9
+
10
+ When used as the data value for a Section tag, the lambda MUST be treatable
11
+ as an arity 1 function, and invoked as such (passing a String containing the
12
+ unprocessed section contents). The returned value MUST be rendered against
13
+ the current delimiters, then interpolated in place of the section.
14
+ tests:
15
+ - name: Interpolation
16
+ desc: A lambda's return value should be interpolated.
17
+ data:
18
+ lambda: !code
19
+ ruby: 'proc { "world" }'
20
+ perl: 'sub { "world" }'
21
+ js: 'function() { return "world" }'
22
+ php: 'return "world";'
23
+ python: 'lambda: "world"'
24
+ clojure: '(fn [] "world")'
25
+ template: "Hello, {{lambda}}!"
26
+ expected: "Hello, world!"
27
+
28
+ - name: Interpolation - Expansion
29
+ desc: A lambda's return value should be parsed.
30
+ data:
31
+ planet: "world"
32
+ lambda: !code
33
+ ruby: 'proc { "{{planet}}" }'
34
+ perl: 'sub { "{{planet}}" }'
35
+ js: 'function() { return "{{planet}}" }'
36
+ php: 'return "{{planet}}";'
37
+ python: 'lambda: "{{planet}}"'
38
+ clojure: '(fn [] "{{planet}}")'
39
+ template: "Hello, {{lambda}}!"
40
+ expected: "Hello, world!"
41
+
42
+ - name: Interpolation - Alternate Delimiters
43
+ desc: A lambda's return value should parse with the default delimiters.
44
+ data:
45
+ planet: "world"
46
+ lambda: !code
47
+ ruby: 'proc { "|planet| => {{planet}}" }'
48
+ perl: 'sub { "|planet| => {{planet}}" }'
49
+ js: 'function() { return "|planet| => {{planet}}" }'
50
+ php: 'return "|planet| => {{planet}}";'
51
+ python: 'lambda: "|planet| => {{planet}}"'
52
+ clojure: '(fn [] "|planet| => {{planet}}")'
53
+ template: "{{= | | =}}\nHello, (|&lambda|)!"
54
+ expected: "Hello, (|planet| => world)!"
55
+
56
+ - name: Interpolation - Multiple Calls
57
+ desc: Interpolated lambdas should not be cached.
58
+ data:
59
+ lambda: !code
60
+ ruby: 'proc { $calls ||= 0; $calls += 1 }'
61
+ perl: 'sub { no strict; $calls += 1 }'
62
+ js: 'function() { return (g=(function(){return this})()).calls=(g.calls||0)+1 }'
63
+ php: 'global $calls; return ++$calls;'
64
+ python: 'lambda: globals().update(calls=globals().get("calls",0)+1) or calls'
65
+ clojure: '(def g (atom 0)) (fn [] (swap! g inc))'
66
+ template: '{{lambda}} == {{{lambda}}} == {{lambda}}'
67
+ expected: '1 == 2 == 3'
68
+
69
+ - name: Escaping
70
+ desc: Lambda results should be appropriately escaped.
71
+ data:
72
+ lambda: !code
73
+ ruby: 'proc { ">" }'
74
+ perl: 'sub { ">" }'
75
+ js: 'function() { return ">" }'
76
+ php: 'return ">";'
77
+ python: 'lambda: ">"'
78
+ clojure: '(fn [] ">")'
79
+ template: "<{{lambda}}{{{lambda}}}"
80
+ expected: "<&gt;>"
81
+
82
+ - name: Section
83
+ desc: Lambdas used for sections should receive the raw section string.
84
+ data:
85
+ x: 'Error!'
86
+ lambda: !code
87
+ ruby: 'proc { |text| text == "{{x}}" ? "yes" : "no" }'
88
+ perl: 'sub { $_[0] eq "{{x}}" ? "yes" : "no" }'
89
+ js: 'function(txt) { return (txt == "{{x}}" ? "yes" : "no") }'
90
+ php: 'return ($text == "{{x}}") ? "yes" : "no";'
91
+ python: 'lambda text: text == "{{x}}" and "yes" or "no"'
92
+ clojure: '(fn [text] (if (= text "{{x}}") "yes" "no"))'
93
+ template: "<{{#lambda}}{{x}}{{/lambda}}>"
94
+ expected: "<yes>"
95
+
96
+ - name: Section - Expansion
97
+ desc: Lambdas used for sections should have their results parsed.
98
+ data:
99
+ planet: "Earth"
100
+ lambda: !code
101
+ ruby: 'proc { |text| "#{text}{{planet}}#{text}" }'
102
+ perl: 'sub { $_[0] . "{{planet}}" . $_[0] }'
103
+ js: 'function(txt) { return txt + "{{planet}}" + txt }'
104
+ php: 'return $text . "{{planet}}" . $text;'
105
+ python: 'lambda text: "%s{{planet}}%s" % (text, text)'
106
+ clojure: '(fn [text] (str text "{{planet}}" text))'
107
+ template: "<{{#lambda}}-{{/lambda}}>"
108
+ expected: "<-Earth->"
109
+
110
+ - name: Section - Alternate Delimiters
111
+ desc: Lambdas used for sections should parse with the current delimiters.
112
+ data:
113
+ planet: "Earth"
114
+ lambda: !code
115
+ ruby: 'proc { |text| "#{text}{{planet}} => |planet|#{text}" }'
116
+ perl: 'sub { $_[0] . "{{planet}} => |planet|" . $_[0] }'
117
+ js: 'function(txt) { return txt + "{{planet}} => |planet|" + txt }'
118
+ php: 'return $text . "{{planet}} => |planet|" . $text;'
119
+ python: 'lambda text: "%s{{planet}} => |planet|%s" % (text, text)'
120
+ clojure: '(fn [text] (str text "{{planet}} => |planet|" text))'
121
+ template: "{{= | | =}}<|#lambda|-|/lambda|>"
122
+ expected: "<-{{planet}} => Earth->"
123
+
124
+ - name: Section - Multiple Calls
125
+ desc: Lambdas used for sections should not be cached.
126
+ data:
127
+ lambda: !code
128
+ ruby: 'proc { |text| "__#{text}__" }'
129
+ perl: 'sub { "__" . $_[0] . "__" }'
130
+ js: 'function(txt) { return "__" + txt + "__" }'
131
+ php: 'return "__" . $text . "__";'
132
+ python: 'lambda text: "__%s__" % (text)'
133
+ clojure: '(fn [text] (str "__" text "__"))'
134
+ template: '{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}'
135
+ expected: '__FILE__ != __LINE__'
136
+
137
+ - name: Inverted Section
138
+ desc: Lambdas used for inverted sections should be considered truthy.
139
+ data:
140
+ static: 'static'
141
+ lambda: !code
142
+ ruby: 'proc { |text| false }'
143
+ perl: 'sub { 0 }'
144
+ js: 'function(txt) { return false }'
145
+ php: 'return false;'
146
+ python: 'lambda text: 0'
147
+ clojure: '(fn [text] false)'
148
+ template: "<{{^lambda}}{{static}}{{/lambda}}>"
149
+ expected: "<>"