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,14 @@
1
+ /*
2
+ * Copyright 2011 Twitter, Inc.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */var HoganTemplate=function(){function a(a){this.text=a}function h(a){var h=String(a===null?"":a);return g.test(h)?h.replace(b,"&amp;").replace(c,"&lt;").replace(d,"&gt;").replace(e,"&#39;").replace(f,"&quot;"):h}a.prototype={r:function(a,b){return""},v:h,render:function(a,b){return this.r(a,b)},rp:function(a,b,c,d){var e=c[a];return e?e.render(b,c):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b),d;for(var f=0;f<e.length;f++)a.push(e[f]),d+=c(a,b),a.pop();return d},s:function(a,b,c,d,e,f){if(i(a)&&a.length===0)return!1;!d&&typeof a=="function"&&(a=this.ls(a,b,c,e,f));var g=a===""||!!a;return!d&&g&&b&&b.push(typeof a=="object"?a:b[b.length-1]),g},d:function(a,b,c,d){if(a==="."&&i(b[b.length-2]))return b[b.length-1];var e=a.split("."),f=this.f(e[0],b,c,d),g=null;for(var h=1;h<e.length;h++)f&&typeof f=="object"&&e[h]in f?(g=f,f=f[e[h]]):f="";return d&&!f?!1:(!d&&typeof f=="function"&&(b.push(g),f=this.lv(f,b,c),b.pop()),f)},f:function(a,b,c,d){var e=!1,f=null,g=!1;for(var h=b.length-1;h>=0;h--){f=b[h];if(f&&typeof f=="object"&&a in f){e=f[a],g=!0;break}}return g?(!d&&typeof e=="function"&&(e=this.lv(e,b,c)),e):d?!1:""},ho:function(a,b,c,d){var e=a.call(b,d,function(a){return Hogan.compile(a).render(b)}),f=Hogan.compile(e.toString()).render(b,c);return this.b=f,!1},b:"",ls:function(a,b,c,d,e){var f=b[b.length-1];if(a.length>0)return this.ho(a,f,c,this.text.substring(d,e));var g=a.call(f);return typeof g=="function"?this.ho(g,f,c,this.text.substring(d,e)):g},lv:function(a,b,c){var d=b[b.length-1];return Hogan.compile(a.call(d).toString()).render(d,c)}};var b=/&/g,c=/</g,d=/>/g,e=/\'/g,f=/\"/g,g=/[&<>\"\']/,i=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"};return a}(),Hogan=function(){function a(a){function s(){l.length>0&&(m.push(new String(l)),l="")}function t(){var a=!0;for(var b=p;b<m.length;b++){a=m[b].tag&&d[m[b].tag]<d._v||!m[b].tag&&m[b].match(c)==null;if(!a)return!1}return a}function u(a,b){s();if(a&&t())for(var c=p;c<m.length;c++)m[c].tag||m.splice(c,1);else b||m.push({tag:"\n"});n=!1,p=m.length}function v(a,c){var d="="+r,e=a.indexOf(d,c),f=b(a.substring(a.indexOf("=",c)+1,e)).split(" ");return q=f[0],r=f[1],e+d.length-1}var f=a.length,g=0,h=1,i=2,j=g,k=null,l="",m=[],n=!1,o=0,p=0,q="{{",r="}}";for(o=0;o<f;o++)if(j==g)e(q,a,o)?(--o,s(),j=h):a[o]=="\n"?u(n):l+=a[o];else if(j==h){o+=q.length-1;var w=d[a[o+1]];k=w?a[o+1]:"_v",n=o,k=="="?(o=v(a,o),j=g):(w&&o++,j=i)}else e(r,a,o)?(o+=r.length-1,m.push({tag:k,n:b(l),i:k=="/"?n-1:o+1}),l="",j=g,k=="{"&&o++):l+=a[o];return u(n,!0),m}function b(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function e(a,b,c){if(b[c]!=a[0])return!1;for(var d=1,e=a.length;d<e;d++)if(b[c+d]!=a[d])return!1;return!0}function f(a,b,c,d){var e=[],i=null,j=null;while(a.length>0){j=a.shift();if(j.tag=="#"||j.tag=="^"||g(j,d))c.push(j),j.nodes=f(a,j.tag,c,d),e.push(j);else{if(j.tag=="/"){if(c.length==0)throw new Error("Closing tag without opener: /"+j.n);i=c.pop();if(j.n!=i.n&&!h(j.n,i.n,d))throw new Error("Nesting error: "+i.n+" vs. "+j.n);return i.end=j.i,e}e.push(j)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function g(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function h(a,b,c){for(var d=0,e=c.length;d<e;d++)if(c[d].c==a&&c[d].o==b)return!0}function i(a,b,c){var d='var c = [cx];var b = "";var _ = this;'+p(a)+"return b;";if(c.asString)return"function(cx,p){"+d+";};";var e=new HoganTemplate(b);return e.r=new Function("cx","p",d),e}function n(a){return a.replace(m,"\\\\").replace(j,'\\"').replace(k,"\\n").replace(l,"\\r")}function o(a){return~a.indexOf(".")?"d":"f"}function p(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=q(a[c].nodes,a[c].n,o(a[c].n),a[c].i,a[c].end):e=="^"?b+=r(a[c].nodes,a[c].n,o(a[c].n)):e=="<"||e==">"?b+=s(a[c].n):e=="{"||e=="&"?b+=t(a[c].n,o(a[c].n)):e=="\n"?b+=v("\n"):e=="_v"?b+=u(a[c].n,o(a[c].n)):e===undefined&&(b+=v(a[c]))}return b}function q(a,b,c,d,e){var f="if(_.s(_."+c+'("'+n(b)+'",c,p,1),';return f+="c,p,0,"+d+","+e+")){",f+="b += _.rs(c,p,",f+='function(c,p){ var b = "";',f+=p(a),f+="return b;});c.pop();}",f+='else{b += _.b; _.b = ""};',f}function r(a,b,c){var d="if (!_.s(_."+c+'("'+n(b)+'",c,p,1),c,p,1,0,0)){';return d+=p(a),d+="};",d}function s(a){return'b += _.rp("'+n(a)+'",c[c.length - 1],p);'}function t(a,b){return"b += (_."+b+'("'+n(a)+'",c,p,0));'}function u(a,b){return"b += (_.v(_."+b+'("'+n(a)+'",c,p,0)));'}function v(a){return'b += "'+n(a)+'";'}var c=/\S/,d={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10},j=/\"/g,k=/\n/g,l=/\r/g,m=/\\/g;return{scan:a,parse:function(a,b){return b=b||{},f(a,"",[],b.sectionTags||[])},cache:{},compile:function(b,c){c=c||{};var d=this.cache[b];return d?d:(d=i(this.parse(a(b),c),b,c),this.cache[b]=d)}}}();typeof module!="undefined"&&module.exports?(module.exports=Hogan,module.exports.Template=HoganTemplate):typeof exports!="undefined"&&(exports.Hogan=Hogan,exports.HoganTemplate=HoganTemplate);
@@ -0,0 +1,545 @@
1
+ /*
2
+ * Copyright 2011 Twitter, Inc.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ var HoganTemplate = (function () {
17
+
18
+ function constructor(text) {
19
+ this.text = text;
20
+ }
21
+
22
+ constructor.prototype = {
23
+
24
+ // render: replaced by generated code.
25
+ r: function (context, partials, indent) { return ''; },
26
+
27
+ // variable escaping
28
+ v: hoganEscape,
29
+
30
+ render: function render(context, partials, indent) {
31
+ return this.r(context, partials, indent);
32
+ },
33
+
34
+ // tries to find a partial in the curent scope and render it
35
+ rp: function(name, context, partials, indent) {
36
+ var partial = partials[name];
37
+
38
+ if (!partial) {
39
+ return '';
40
+ }
41
+
42
+ return partial.r(context, partials, indent);
43
+ },
44
+
45
+ // render a section
46
+ rs: function(context, partials, section) {
47
+ var buf = '',
48
+ tail = context[context.length - 1];
49
+
50
+ if (!isArray(tail)) {
51
+ return buf = section(context, partials);
52
+ }
53
+
54
+ for (var i = 0; i < tail.length; i++) {
55
+ context.push(tail[i]);
56
+ buf += section(context, partials);
57
+ context.pop();
58
+ }
59
+
60
+ return buf;
61
+ },
62
+
63
+ // maybe start a section
64
+ s: function(val, ctx, partials, inverted, start, end, tags) {
65
+ var pass;
66
+
67
+ if (isArray(val) && val.length === 0) {
68
+ return false;
69
+ }
70
+
71
+ if (!inverted && typeof val == 'function') {
72
+ val = this.ls(val, ctx, partials, start, end, tags);
73
+ }
74
+
75
+ pass = (val === '') || !!val;
76
+
77
+ if (!inverted && pass && ctx) {
78
+ ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
79
+ }
80
+
81
+ return pass;
82
+ },
83
+
84
+ // find values with dotted names
85
+ d: function(key, ctx, partials, returnFound) {
86
+
87
+ var names = key.split('.'),
88
+ val = this.f(names[0], ctx, partials, returnFound),
89
+ cx = null;
90
+
91
+ if (key === '.' && isArray(ctx[ctx.length - 2])) {
92
+ return ctx[ctx.length - 1];
93
+ }
94
+
95
+ for (var i = 1; i < names.length; i++) {
96
+ if (val && typeof val == 'object' && names[i] in val) {
97
+ cx = val;
98
+ val = val[names[i]];
99
+ } else {
100
+ val = '';
101
+ }
102
+ }
103
+
104
+ if (returnFound && !val) {
105
+ return false;
106
+ }
107
+
108
+ if (!returnFound && typeof val == 'function') {
109
+ ctx.push(cx);
110
+ val = this.lv(val, ctx, partials);
111
+ ctx.pop();
112
+ }
113
+
114
+ return val;
115
+ },
116
+
117
+ // find values with normal names
118
+ f: function(key, ctx, partials, returnFound) {
119
+ var val = false,
120
+ v = null,
121
+ found = false;
122
+
123
+ for (var i = ctx.length - 1; i >= 0; i--) {
124
+ v = ctx[i];
125
+ if (v && typeof v == 'object' && key in v) {
126
+ val = v[key];
127
+ found = true;
128
+ break;
129
+ }
130
+ }
131
+
132
+ if (!found) {
133
+ return (returnFound) ? false : "";
134
+ }
135
+
136
+ if (!returnFound && typeof val == 'function') {
137
+ val = this.lv(val, ctx, partials);
138
+ }
139
+
140
+ return val;
141
+ },
142
+
143
+ // higher order templates
144
+ ho: function(val, cx, partials, text, tags) {
145
+ var t = val.call(cx, text, function(t) {
146
+ return Hogan.compile(t, {delimiters: tags}).render(cx, partials);
147
+ });
148
+ var s = Hogan.compile(t.toString(), {delimiters: tags}).render(cx, partials);
149
+ this.b = s;
150
+ return false;
151
+ },
152
+
153
+ // higher order template result buffer
154
+ b: '',
155
+
156
+ // lambda replace section
157
+ ls: function(val, ctx, partials, start, end, tags) {
158
+ var cx = ctx[ctx.length - 1],
159
+ t = val.call(cx);
160
+
161
+ if (val.length > 0) {
162
+ return this.ho(val, cx, partials, this.text.substring(start, end), tags);
163
+ }
164
+
165
+ if (typeof t == 'function') {
166
+ return this.ho(t, cx, partials, this.text.substring(start, end), tags);
167
+ }
168
+
169
+ return t;
170
+ },
171
+
172
+ // lambda replace variable
173
+ lv: function(val, ctx, partials) {
174
+ var cx = ctx[ctx.length - 1];
175
+ return Hogan.compile(val.call(cx).toString()).render(cx, partials);
176
+ }
177
+
178
+ };
179
+
180
+ var rAmp = /&/g,
181
+ rLt = /</g,
182
+ rGt = />/g,
183
+ rApos =/\'/g,
184
+ rQuot = /\"/g,
185
+ hChars =/[&<>\"\']/;
186
+
187
+ function hoganEscape(str) {
188
+ str = String(str === null ? '' : str);
189
+ return hChars.test(str) ?
190
+ str
191
+ .replace(rAmp,'&amp;')
192
+ .replace(rLt,'&lt;')
193
+ .replace(rGt,'&gt;')
194
+ .replace(rApos,'&#39;')
195
+ .replace(rQuot, '&quot;') :
196
+ str;
197
+ }
198
+
199
+ var isArray = Array.isArray || function(a) {
200
+ return Object.prototype.toString.call(a) === '[object Array]';
201
+ };
202
+
203
+ return constructor;
204
+
205
+ })();
206
+
207
+ var Hogan = (function () {
208
+
209
+ // Setup regex assignments
210
+ // remove whitespace according to Mustache spec
211
+ var rIsWhitespace = /\S/,
212
+ rQuot = /\"/g,
213
+ rNewline = /\n/g,
214
+ rCr = /\r/g,
215
+ rSlash = /\\/g,
216
+ tagTypes = {
217
+ '#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
218
+ '<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
219
+ };
220
+
221
+ function scan(text, delimiters) {
222
+ var len = text.length,
223
+ IN_TEXT = 0,
224
+ IN_TAG_TYPE = 1,
225
+ IN_TAG = 2,
226
+ state = IN_TEXT,
227
+ tagType = null,
228
+ tag = null,
229
+ buf = '',
230
+ tokens = [],
231
+ seenTag = false,
232
+ i = 0,
233
+ lineStart = 0,
234
+ otag = '{{',
235
+ ctag = '}}';
236
+
237
+ function addBuf() {
238
+ if (buf.length > 0) {
239
+ tokens.push(new String(buf));
240
+ buf = '';
241
+ }
242
+ }
243
+
244
+ function lineIsWhitespace() {
245
+ var isAllWhitespace = true;
246
+ for (var j = lineStart; j < tokens.length; j++) {
247
+ isAllWhitespace =
248
+ (tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
249
+ (!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
250
+ if (!isAllWhitespace) {
251
+ return false;
252
+ }
253
+ }
254
+
255
+ return isAllWhitespace;
256
+ }
257
+
258
+ function filterLine(haveSeenTag, noNewLine) {
259
+ addBuf();
260
+
261
+ if (haveSeenTag && lineIsWhitespace()) {
262
+ for (var j = lineStart, next; j < tokens.length; j++) {
263
+ if (!tokens[j].tag) {
264
+ if ((next = tokens[j+1]) && next.tag == '>') {
265
+ // set indent to token value
266
+ next.indent = tokens[j].toString()
267
+ }
268
+ tokens.splice(j, 1);
269
+ }
270
+ }
271
+ } else if (!noNewLine) {
272
+ tokens.push({tag:'\n'});
273
+ }
274
+
275
+ seenTag = false;
276
+ lineStart = tokens.length;
277
+ }
278
+
279
+ function changeDelimiters(text, index) {
280
+ var close = '=' + ctag,
281
+ closeIndex = text.indexOf(close, index),
282
+ delimiters = trim(
283
+ text.substring(text.indexOf('=', index) + 1, closeIndex)
284
+ ).split(' ');
285
+
286
+ otag = delimiters[0];
287
+ ctag = delimiters[1];
288
+
289
+ return closeIndex + close.length - 1;
290
+ }
291
+
292
+ if (delimiters) {
293
+ delimiters = delimiters.split(' ');
294
+ otag = delimiters[0];
295
+ ctag = delimiters[1];
296
+ }
297
+
298
+ for (i = 0; i < len; i++) {
299
+ if (state == IN_TEXT) {
300
+ if (tagChange(otag, text, i)) {
301
+ --i;
302
+ addBuf();
303
+ state = IN_TAG_TYPE;
304
+ } else {
305
+ if (text.charAt(i) == '\n') {
306
+ filterLine(seenTag);
307
+ } else {
308
+ buf += text.charAt(i);
309
+ }
310
+ }
311
+ } else if (state == IN_TAG_TYPE) {
312
+ i += otag.length - 1;
313
+ tag = tagTypes[text.charAt(i + 1)];
314
+ tagType = tag ? text.charAt(i + 1) : '_v';
315
+ if (tagType == '=') {
316
+ i = changeDelimiters(text, i);
317
+ state = IN_TEXT;
318
+ } else {
319
+ if (tag) {
320
+ i++;
321
+ }
322
+ state = IN_TAG;
323
+ }
324
+ seenTag = i;
325
+ } else {
326
+ if (tagChange(ctag, text, i)) {
327
+ tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
328
+ i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
329
+ buf = '';
330
+ i += ctag.length - 1;
331
+ state = IN_TEXT;
332
+ if (tagType == '{') {
333
+ i++;
334
+ }
335
+ } else {
336
+ buf += text.charAt(i);
337
+ }
338
+ }
339
+ }
340
+
341
+ filterLine(seenTag, true);
342
+
343
+ return tokens;
344
+ }
345
+
346
+ function trim(s) {
347
+ if (s.trim) {
348
+ return s.trim();
349
+ }
350
+
351
+ return s.replace(/^\s*|\s*$/g, '');
352
+ }
353
+
354
+ function tagChange(tag, text, index) {
355
+ if (text.charAt(index) != tag.charAt(0)) {
356
+ return false;
357
+ }
358
+
359
+ for (var i = 1, l = tag.length; i < l; i++) {
360
+ if (text.charAt(index + i) != tag.charAt(i)) {
361
+ return false;
362
+ }
363
+ }
364
+
365
+ return true;
366
+ }
367
+
368
+ function buildTree(tokens, kind, stack, customTags) {
369
+ var instructions = [],
370
+ opener = null,
371
+ token = null;
372
+
373
+ while (tokens.length > 0) {
374
+ token = tokens.shift();
375
+ if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
376
+ stack.push(token);
377
+ token.nodes = buildTree(tokens, token.tag, stack, customTags);
378
+ instructions.push(token);
379
+ } else if (token.tag == '/') {
380
+ if (stack.length === 0) {
381
+ throw new Error('Closing tag without opener: /' + token.n);
382
+ }
383
+ opener = stack.pop();
384
+ if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
385
+ throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
386
+ }
387
+ opener.end = token.i;
388
+ return instructions;
389
+ } else {
390
+ instructions.push(token);
391
+ }
392
+ }
393
+
394
+ if (stack.length > 0) {
395
+ throw new Error('missing closing tag: ' + stack.pop().n);
396
+ }
397
+
398
+ return instructions;
399
+ }
400
+
401
+ function isOpener(token, tags) {
402
+ for (var i = 0, l = tags.length; i < l; i++) {
403
+ if (tags[i].o == token.n) {
404
+ token.tag = '#';
405
+ return true;
406
+ }
407
+ }
408
+ }
409
+
410
+ function isCloser(close, open, tags) {
411
+ for (var i = 0, l = tags.length; i < l; i++) {
412
+ if (tags[i].c == close && tags[i].o == open) {
413
+ return true;
414
+ }
415
+ }
416
+ }
417
+
418
+ function generate(tree, text, options) {
419
+ var code = 'i = i || "";var c = [cx];var b = i + "";var _ = this;'
420
+ + walk(tree)
421
+ + 'return b;';
422
+
423
+ if (options.asString) {
424
+ return 'function(cx,p,i){' + code + ';}';
425
+ }
426
+
427
+ var template = new HoganTemplate(text);
428
+ template.r = new Function('cx', 'p', 'i', code);
429
+ return template;
430
+ }
431
+
432
+ function esc(s) {
433
+ return s.replace(rSlash, '\\\\')
434
+ .replace(rQuot, '\\\"')
435
+ .replace(rNewline, '\\n')
436
+ .replace(rCr, '\\r');
437
+ }
438
+
439
+ function chooseMethod(s) {
440
+ return (~s.indexOf('.')) ? 'd' : 'f';
441
+ }
442
+
443
+ function walk(tree) {
444
+ var code = '';
445
+ for (var i = 0, l = tree.length; i < l; i++) {
446
+ var tag = tree[i].tag;
447
+ if (tag == '#') {
448
+ code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
449
+ tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
450
+ } else if (tag == '^') {
451
+ code += invertedSection(tree[i].nodes, tree[i].n,
452
+ chooseMethod(tree[i].n));
453
+ } else if (tag == '<' || tag == '>') {
454
+ code += partial(tree[i]);
455
+ } else if (tag == '{' || tag == '&') {
456
+ code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
457
+ } else if (tag == '\n') {
458
+ code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
459
+ } else if (tag == '_v') {
460
+ code += variable(tree[i].n, chooseMethod(tree[i].n));
461
+ } else if (tag === undefined) {
462
+ code += text('"' + esc(tree[i]) + '"');
463
+ }
464
+ }
465
+ return code;
466
+ }
467
+
468
+ function section(nodes, id, method, start, end, tags) {
469
+ return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
470
+ 'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
471
+ 'b += _.rs(c,p,' +
472
+ 'function(c,p){ var b = "";' +
473
+ walk(nodes) +
474
+ 'return b;});c.pop();}' +
475
+ 'else{b += _.b; _.b = ""};';
476
+ }
477
+
478
+ function invertedSection(nodes, id, method) {
479
+ return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
480
+ walk(nodes) +
481
+ '};';
482
+ }
483
+
484
+ function partial(tok) {
485
+ return 'b += _.rp("' + esc(tok.n) + '",c[c.length - 1],p,"' + (tok.indent || '') + '");';
486
+ }
487
+
488
+ function tripleStache(id, method) {
489
+ return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
490
+ }
491
+
492
+ function variable(id, method) {
493
+ return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
494
+ }
495
+
496
+ function text(id) {
497
+ return 'b += ' + id + ';';
498
+ }
499
+
500
+ return ({
501
+ scan: scan,
502
+
503
+ parse: function(tokens, options) {
504
+ options = options || {};
505
+ return buildTree(tokens, '', [], options.sectionTags || []);
506
+ },
507
+
508
+ cache: {},
509
+
510
+ compile: function(text, options) {
511
+ // options
512
+ //
513
+ // asString: false (default)
514
+ //
515
+ // sectionTags: [{o: '_foo', c: 'foo'}]
516
+ // An array of object with o and c fields that indicate names for custom
517
+ // section tags. The example above allows parsing of {{_foo}}{{/foo}}.
518
+ //
519
+ // delimiters: A string that overrides the default delimiters.
520
+ // Example: "<% %>"
521
+ //
522
+ options = options || {};
523
+
524
+ var t = this.cache[text];
525
+
526
+ if (t) {
527
+ return t;
528
+ }
529
+
530
+ t = generate(this.parse(scan(text, options.delimiters), options), text, options);
531
+ return this.cache[text] = t;
532
+ }
533
+ });
534
+ })();
535
+
536
+ // Export the hogan constructor for Node.js and CommonJS.
537
+ if (typeof module !== 'undefined' && module.exports) {
538
+ module.exports = Hogan;
539
+ module.exports.Template = HoganTemplate;
540
+ } else if (typeof define === 'function' && define.amd) {
541
+ define(function () { return Hogan; });
542
+ } else if (typeof exports !== 'undefined') {
543
+ exports.Hogan = Hogan;
544
+ exports.HoganTemplate = HoganTemplate;
545
+ }