sass-twitter-bootstrap 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +14 -0
- data/LICENSE +176 -0
- data/Makefile +94 -0
- data/README.md +217 -0
- data/Rakefile +52 -0
- data/bootstrap-2.0.4.css +4661 -0
- data/bootstrap-2.0.4.min.css +9 -0
- data/bootstrap-responsive-2.0.4.css +932 -0
- data/bootstrap-responsive-2.0.4.min.css +9 -0
- data/docs/assets/css/bootstrap-responsive.css +932 -0
- data/docs/assets/css/bootstrap.css +4661 -0
- data/docs/assets/css/docs.css +846 -0
- data/docs/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
- data/docs/assets/ico/favicon.ico +0 -0
- data/docs/assets/img/bird.png +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-01.jpg +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-02.jpg +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-03.jpg +0 -0
- data/docs/assets/img/browsers.png +0 -0
- data/docs/assets/img/example-sites/fleetio.png +0 -0
- data/docs/assets/img/example-sites/jshint.png +0 -0
- data/docs/assets/img/example-sites/kippt.png +0 -0
- data/docs/assets/img/example-sites/soundready.png +0 -0
- data/docs/assets/img/examples/bootstrap-example-fluid.jpg +0 -0
- data/docs/assets/img/examples/bootstrap-example-hero.jpg +0 -0
- data/docs/assets/img/examples/bootstrap-example-starter.jpg +0 -0
- data/docs/assets/img/github-16px.png +0 -0
- data/docs/assets/img/glyphicons-halflings-white.png +0 -0
- data/docs/assets/img/glyphicons-halflings.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_009_magic.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_042_group.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_079_podium.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_082_roundabout.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_155_show_thumbnails.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_163_iphone.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_214_resize_small.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_266_book_open.png +0 -0
- data/docs/assets/img/grid-18px-masked.png +0 -0
- data/docs/assets/img/icon-css3.png +0 -0
- data/docs/assets/img/icon-github.png +0 -0
- data/docs/assets/img/icon-html5.png +0 -0
- data/docs/assets/img/icon-twitter.png +0 -0
- data/docs/assets/img/less-logo-large.png +0 -0
- data/docs/assets/img/less-small.png +0 -0
- data/docs/assets/img/responsive-illustrations.png +0 -0
- data/docs/assets/js/README.md +106 -0
- data/docs/assets/js/application.js +184 -0
- data/docs/assets/js/bootstrap-alert.js +90 -0
- data/docs/assets/js/bootstrap-button.js +96 -0
- data/docs/assets/js/bootstrap-carousel.js +169 -0
- data/docs/assets/js/bootstrap-collapse.js +157 -0
- data/docs/assets/js/bootstrap-dropdown.js +100 -0
- data/docs/assets/js/bootstrap-modal.js +218 -0
- data/docs/assets/js/bootstrap-popover.js +98 -0
- data/docs/assets/js/bootstrap-scrollspy.js +151 -0
- data/docs/assets/js/bootstrap-tab.js +135 -0
- data/docs/assets/js/bootstrap-tooltip.js +275 -0
- data/docs/assets/js/bootstrap-transition.js +61 -0
- data/docs/assets/js/bootstrap-typeahead.js +285 -0
- data/docs/assets/js/bootstrap.js +1825 -0
- data/docs/assets/js/bootstrap.min.js +6 -0
- data/docs/assets/js/google-code-prettify/prettify.css +30 -0
- data/docs/assets/js/google-code-prettify/prettify.js +28 -0
- data/docs/assets/js/jquery.js +9252 -0
- data/docs/base-css.html +1710 -0
- data/docs/build/index.js +44 -0
- data/docs/build/node_modules/.bin/hulk +93 -0
- data/docs/build/node_modules/hogan.js/.git_ignore +1 -0
- data/docs/build/node_modules/hogan.js/.gitmodules +3 -0
- data/docs/build/node_modules/hogan.js/LICENSE +177 -0
- data/docs/build/node_modules/hogan.js/Makefile +62 -0
- data/docs/build/node_modules/hogan.js/README.md +93 -0
- data/docs/build/node_modules/hogan.js/bin/hulk +93 -0
- data/docs/build/node_modules/hogan.js/lib/compiler.js +348 -0
- data/docs/build/node_modules/hogan.js/lib/hogan.js +20 -0
- data/docs/build/node_modules/hogan.js/lib/template.js +233 -0
- data/docs/build/node_modules/hogan.js/package.json +20 -0
- data/docs/build/node_modules/hogan.js/test/html/list.html +8 -0
- data/docs/build/node_modules/hogan.js/test/index.html +13 -0
- data/docs/build/node_modules/hogan.js/test/index.js +848 -0
- data/docs/build/node_modules/hogan.js/test/mustache.js +90 -0
- data/docs/build/node_modules/hogan.js/test/spec.js +77 -0
- data/docs/build/node_modules/hogan.js/test/spec/Changes +31 -0
- data/docs/build/node_modules/hogan.js/test/spec/README.md +65 -0
- data/docs/build/node_modules/hogan.js/test/spec/Rakefile +27 -0
- data/docs/build/node_modules/hogan.js/test/spec/TESTING.md +46 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/comments.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/comments.yml +103 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.yml +158 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.yml +230 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.yml +193 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/partials.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/partials.yml +109 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/sections.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/sections.yml +256 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.json +1 -0
- data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.yml +149 -0
- data/docs/build/node_modules/hogan.js/test/templates/list.mustache +8 -0
- data/docs/build/node_modules/hogan.js/tools/release.js +74 -0
- data/docs/build/node_modules/hogan.js/tools/web_templates.js +32 -0
- data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.js +500 -0
- data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.min.js +14 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.js +500 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.min.js +14 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.js +545 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.min.js +5 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.amd.js +576 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.common.js +576 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.js +572 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.amd.js +5 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.common.js +5 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.js +5 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.mustache.js +5 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.mustache.js +619 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.js +233 -0
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.min.js +5 -0
- data/docs/build/node_modules/hogan.js/web/favicon.ico +0 -0
- data/docs/build/node_modules/hogan.js/web/images/logo.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/noise.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/small-hogan-icon.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/stripes.png +0 -0
- data/docs/build/node_modules/hogan.js/web/index.html.mustache +139 -0
- data/docs/build/node_modules/hogan.js/web/stylesheets/layout.css +206 -0
- data/docs/build/node_modules/hogan.js/web/stylesheets/skeleton.css +236 -0
- data/docs/build/node_modules/hogan.js/wrappers/amd.js.mustache +21 -0
- data/docs/build/node_modules/hogan.js/wrappers/common.js.mustache +21 -0
- data/docs/build/node_modules/hogan.js/wrappers/js.mustache +17 -0
- data/docs/build/node_modules/hogan.js/wrappers/mustache.js.mustache +64 -0
- data/docs/build/package.json +6 -0
- data/docs/components.html +1931 -0
- data/docs/download.html +454 -0
- data/docs/examples.html +147 -0
- data/docs/examples/fluid.html +162 -0
- data/docs/examples/hero.html +109 -0
- data/docs/examples/starter-template.html +79 -0
- data/docs/index.html +259 -0
- data/docs/javascript.html +1520 -0
- data/docs/less.html +1060 -0
- data/docs/scaffolding.html +671 -0
- data/docs/templates/layout.mustache +146 -0
- data/docs/templates/pages/base-css.mustache +1594 -0
- data/docs/templates/pages/components.mustache +1815 -0
- data/docs/templates/pages/download.mustache +338 -0
- data/docs/templates/pages/examples.mustache +31 -0
- data/docs/templates/pages/index.mustache +144 -0
- data/docs/templates/pages/javascript.mustache +1405 -0
- data/docs/templates/pages/less.mustache +944 -0
- data/docs/templates/pages/scaffolding.mustache +555 -0
- data/docs/templates/pages/upgrading.mustache +194 -0
- data/docs/upgrading.html +310 -0
- data/js/tests/index.html +54 -0
- data/js/tests/phantom.js +63 -0
- data/js/tests/server.js +14 -0
- data/js/tests/unit/bootstrap-alert.js +56 -0
- data/js/tests/unit/bootstrap-button.js +77 -0
- data/js/tests/unit/bootstrap-carousel.js +28 -0
- data/js/tests/unit/bootstrap-collapse.js +54 -0
- data/js/tests/unit/bootstrap-dropdown.js +87 -0
- data/js/tests/unit/bootstrap-modal.js +114 -0
- data/js/tests/unit/bootstrap-phantom.js +21 -0
- data/js/tests/unit/bootstrap-popover.js +93 -0
- data/js/tests/unit/bootstrap-scrollspy.js +31 -0
- data/js/tests/unit/bootstrap-tab.js +61 -0
- data/js/tests/unit/bootstrap-tooltip.js +155 -0
- data/js/tests/unit/bootstrap-transition.js +13 -0
- data/js/tests/unit/bootstrap-typeahead.js +148 -0
- data/js/tests/vendor/jquery.js +9252 -0
- data/js/tests/vendor/qunit.css +232 -0
- data/js/tests/vendor/qunit.js +1510 -0
- data/lib/sass-twitter-bootstrap.rb +9 -0
- data/lib/sass/twitter/bootstrap/rails.rb +14 -0
- data/lib/sass/twitter/bootstrap/version.rb +7 -0
- data/package.json +25 -0
- data/sass-twitter-bootstrap.gemspec +19 -0
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/README.md +112 -0
- data/vendor/assets/javascripts/twitter/bootstrap-alert.js +90 -0
- data/vendor/assets/javascripts/twitter/bootstrap-button.js +96 -0
- data/vendor/assets/javascripts/twitter/bootstrap-carousel.js +169 -0
- data/vendor/assets/javascripts/twitter/bootstrap-collapse.js +157 -0
- data/vendor/assets/javascripts/twitter/bootstrap-dropdown.js +100 -0
- data/vendor/assets/javascripts/twitter/bootstrap-modal.js +218 -0
- data/vendor/assets/javascripts/twitter/bootstrap-popover.js +98 -0
- data/vendor/assets/javascripts/twitter/bootstrap-scrollspy.js +151 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tooltip.js +275 -0
- data/vendor/assets/javascripts/twitter/bootstrap-transition.js +61 -0
- data/vendor/assets/javascripts/twitter/bootstrap-typeahead.js +285 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
- data/vendor/assets/stylesheets/tests/css-tests.css +52 -0
- data/vendor/assets/stylesheets/tests/css-tests.html +917 -0
- data/vendor/assets/stylesheets/tests/forms.html +179 -0
- data/vendor/assets/stylesheets/tests/navbar.html +108 -0
- data/vendor/assets/stylesheets/twitter/_accordion.scss +33 -0
- data/vendor/assets/stylesheets/twitter/_alerts.scss +58 -0
- data/vendor/assets/stylesheets/twitter/_breadcrumbs.scss +24 -0
- data/vendor/assets/stylesheets/twitter/_button-groups.scss +191 -0
- data/vendor/assets/stylesheets/twitter/_buttons.scss +191 -0
- data/vendor/assets/stylesheets/twitter/_carousel.scss +121 -0
- data/vendor/assets/stylesheets/twitter/_close.scss +29 -0
- data/vendor/assets/stylesheets/twitter/_code.scss +57 -0
- data/vendor/assets/stylesheets/twitter/_component-animations.scss +20 -0
- data/vendor/assets/stylesheets/twitter/_dropdowns.scss +143 -0
- data/vendor/assets/stylesheets/twitter/_forms.scss +582 -0
- data/vendor/assets/stylesheets/twitter/_grid.scss +5 -0
- data/vendor/assets/stylesheets/twitter/_hero-unit.scss +22 -0
- data/vendor/assets/stylesheets/twitter/_labels-badges.scss +52 -0
- data/vendor/assets/stylesheets/twitter/_layouts.scss +17 -0
- data/vendor/assets/stylesheets/twitter/_mixins.scss +643 -0
- data/vendor/assets/stylesheets/twitter/_modals.scss +90 -0
- data/vendor/assets/stylesheets/twitter/_navbar.scss +358 -0
- data/vendor/assets/stylesheets/twitter/_navs.scss +363 -0
- data/vendor/assets/stylesheets/twitter/_pager.scss +36 -0
- data/vendor/assets/stylesheets/twitter/_pagination.scss +56 -0
- data/vendor/assets/stylesheets/twitter/_popovers.scss +49 -0
- data/vendor/assets/stylesheets/twitter/_progress-bars.scss +117 -0
- data/vendor/assets/stylesheets/twitter/_reset.scss +131 -0
- data/vendor/assets/stylesheets/twitter/_responsive-1200px-min.scss +26 -0
- data/vendor/assets/stylesheets/twitter/_responsive-767px-max.scss +149 -0
- data/vendor/assets/stylesheets/twitter/_responsive-768px-979px.scss +17 -0
- data/vendor/assets/stylesheets/twitter/_responsive-navbar.scss +153 -0
- data/vendor/assets/stylesheets/twitter/_responsive-utilities.scss +41 -0
- data/vendor/assets/stylesheets/twitter/_scaffolding.scss +29 -0
- data/vendor/assets/stylesheets/twitter/_sprites.scss +191 -0
- data/vendor/assets/stylesheets/twitter/_tables.scss +155 -0
- data/vendor/assets/stylesheets/twitter/_thumbnails.scss +47 -0
- data/vendor/assets/stylesheets/twitter/_tooltip.scss +35 -0
- data/vendor/assets/stylesheets/twitter/_type.scss +232 -0
- data/vendor/assets/stylesheets/twitter/_utilities.scss +23 -0
- data/vendor/assets/stylesheets/twitter/_variables.scss +204 -0
- data/vendor/assets/stylesheets/twitter/_wells.scss +27 -0
- data/vendor/assets/stylesheets/twitter/bootstrap.scss +62 -0
- data/vendor/assets/stylesheets/twitter/responsive.scss +48 -0
- metadata +304 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve Copyright 2012 Twitter, Inc.
|
3
|
+
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
|
4
|
+
*/
|
5
|
+
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&").replace(c,"<").replace(d,">").replace(e,"'").replace(f,"""):a}a.Template=function j(a,b,c){a&&(this.r=a),this.c=c,this.text=b||""},a.Template.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.ri([b],c||{},d)},ri:function(a,b,c){return this.r(a,b,c)},rp:function(a,b,c,d){var e=c[a];return e?(this.c&&typeof e=="string"&&(e=this.c.compile(e)),e.ri(b,c,d)):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);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,g){var h;return i(a)&&a.length===0?!1:(typeof a=="function"&&(a=this.ls(a,b,c,d,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];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,e){var f=this.c,g=a.call(b,d,function(a){return f.compile(a,{delimiters:e}).render(b,c)}),h=f.compile(g.toString(),{delimiters:e}).render(b,c);return this.b=h,!1},b:"",ls:function(a,b,c,d,e,f,g){var h=b[b.length-1],i=null;if(!d&&this.c&&a.length>0)return this.ho(a,h,c,this.text.substring(e,f),g);i=a.call(h);if(typeof i=="function"){if(d)return!0;if(this.c)return this.ho(i,h,c,this.text.substring(e,f),g)}return i},lv:function(a,b,c){var d=b[b.length-1],e=a.call(d);return typeof e=="function"&&(e=e.call(d)),e=e.toString(),this.c&&~e.indexOf("{{")?this.c.compile(e).render(d,c):e}};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]"}})(typeof exports!="undefined"?exports:Hogan),function(a){function h(a){a.n.substr(a.n.length-1)==="}"&&(a.n=a.n.substring(0,a.n.length-1))}function i(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function j(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function k(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||l(g,d))c.push(g),g.nodes=k(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!m(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function l(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function m(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 n(a){return'i = i || "";var b = i + "";var _ = this;'+q(a)+"return b;"}function o(a){return a.replace(f,"\\\\").replace(c,'\\"').replace(d,"\\n").replace(e,"\\r")}function p(a){return~a.indexOf(".")?"d":"f"}function q(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=r(a[c].nodes,a[c].n,p(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=s(a[c].nodes,a[c].n,p(a[c].n)):e=="<"||e==">"?b+=t(a[c]):e=="{"||e=="&"?b+=u(a[c].n,p(a[c].n)):e=="\n"?b+=w('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=v(a[c].n,p(a[c].n)):e===undefined&&(b+=w('"'+o(a[c])+'"'))}return b}function r(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+o(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+q(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function s(a,b,c){return"if (!_.s(_."+c+'("'+o(b)+'",c,p,1),c,p,1,0,0,"")){'+q(a)+"};"}function t(a){return'b += _.rp("'+o(a.n)+'",c,p,"'+(a.indent||"")+'");'}function u(a,b){return"b += (_."+b+'("'+o(a)+'",c,p,0));'}function v(a,b){return"b += (_.v(_."+b+'("'+o(a)+'",c,p,0)));'}function w(a){return"b += "+a+";"}var b=/\S/,c=/\"/g,d=/\n/g,e=/\r/g,f=/\\/g,g={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};a.scan=function(c,d){function w(){p.length>0&&(q.push(new String(p)),p="")}function x(){var a=!0;for(var c=t;c<q.length;c++){a=q[c].tag&&g[q[c].tag]<g._v||!q[c].tag&&q[c].match(b)===null;if(!a)return!1}return a}function y(a,b){w();if(a&&x())for(var c=t,d;c<q.length;c++)q[c].tag||((d=q[c+1])&&d.tag==">"&&(d.indent=q[c].toString()),q.splice(c,1));else b||q.push({tag:"\n"});r=!1,t=q.length}function z(a,b){var c="="+v,d=a.indexOf(c,b),e=i(a.substring(a.indexOf("=",b)+1,d)).split(" ");return u=e[0],v=e[1],d+c.length-1}var e=c.length,f=0,k=1,l=2,m=f,n=null,o=null,p="",q=[],r=!1,s=0,t=0,u="{{",v="}}";d&&(d=d.split(" "),u=d[0],v=d[1]);for(s=0;s<e;s++)m==f?j(u,c,s)?(--s,w(),m=k):c.charAt(s)=="\n"?y(r):p+=c.charAt(s):m==k?(s+=u.length-1,o=g[c.charAt(s+1)],n=o?c.charAt(s+1):"_v",n=="="?(s=z(c,s),m=f):(o&&s++,m=l),r=s):j(v,c,s)?(q.push({tag:n,n:i(p),otag:u,ctag:v,i:n=="/"?r-v.length:s+u.length}),p="",s+=v.length-1,m=f,n=="{"&&(v=="}}"?s++:h(q[q.length-1]))):p+=c.charAt(s);return y(r,!0),q},a.generate=function(b,c,d){return d.asString?"function(c,p,i){"+b+";}":new a.Template(new Function("c","p","i",b),c,a)},a.parse=function(a,b){return b=b||{},k(a,"",[],b.sectionTags||[])},a.cache={},a.compile=function(a,b){b=b||{};var c=a+"||"+!!b.asString,d=this.cache[c];return d?d:(d=this.generate(n(this.parse(this.scan(a,b.delimiters),b)),a,b),this.cache[c]=d)}}(typeof exports!="undefined"?exports:Hogan),typeof define=="function"&&define.amd&&define(Hogan)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve Copyright 2012 Twitter, Inc.
|
3
|
+
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
|
4
|
+
*/
|
5
|
+
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&").replace(c,"<").replace(d,">").replace(e,"'").replace(f,"""):a}a.Template=function j(a,b,c){a&&(this.r=a),this.c=c,this.text=b||""},a.Template.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.ri([b],c||{},d)},ri:function(a,b,c){return this.r(a,b,c)},rp:function(a,b,c,d){var e=c[a];return e?(this.c&&typeof e=="string"&&(e=this.c.compile(e)),e.ri(b,c,d)):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);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,g){var h;return i(a)&&a.length===0?!1:(typeof a=="function"&&(a=this.ls(a,b,c,d,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];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,e){var f=this.c,g=a.call(b,d,function(a){return f.compile(a,{delimiters:e}).render(b,c)}),h=f.compile(g.toString(),{delimiters:e}).render(b,c);return this.b=h,!1},b:"",ls:function(a,b,c,d,e,f,g){var h=b[b.length-1],i=null;if(!d&&this.c&&a.length>0)return this.ho(a,h,c,this.text.substring(e,f),g);i=a.call(h);if(typeof i=="function"){if(d)return!0;if(this.c)return this.ho(i,h,c,this.text.substring(e,f),g)}return i},lv:function(a,b,c){var d=b[b.length-1],e=a.call(d);return typeof e=="function"&&(e=e.call(d)),e=e.toString(),this.c&&~e.indexOf("{{")?this.c.compile(e).render(d,c):e}};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]"}})(typeof exports!="undefined"?exports:Hogan),function(a){function h(a){a.n.substr(a.n.length-1)==="}"&&(a.n=a.n.substring(0,a.n.length-1))}function i(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function j(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function k(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||l(g,d))c.push(g),g.nodes=k(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!m(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function l(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function m(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 n(a){return'i = i || "";var b = i + "";var _ = this;'+q(a)+"return b;"}function o(a){return a.replace(f,"\\\\").replace(c,'\\"').replace(d,"\\n").replace(e,"\\r")}function p(a){return~a.indexOf(".")?"d":"f"}function q(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=r(a[c].nodes,a[c].n,p(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=s(a[c].nodes,a[c].n,p(a[c].n)):e=="<"||e==">"?b+=t(a[c]):e=="{"||e=="&"?b+=u(a[c].n,p(a[c].n)):e=="\n"?b+=w('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=v(a[c].n,p(a[c].n)):e===undefined&&(b+=w('"'+o(a[c])+'"'))}return b}function r(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+o(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+q(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function s(a,b,c){return"if (!_.s(_."+c+'("'+o(b)+'",c,p,1),c,p,1,0,0,"")){'+q(a)+"};"}function t(a){return'b += _.rp("'+o(a.n)+'",c,p,"'+(a.indent||"")+'");'}function u(a,b){return"b += (_."+b+'("'+o(a)+'",c,p,0));'}function v(a,b){return"b += (_.v(_."+b+'("'+o(a)+'",c,p,0)));'}function w(a){return"b += "+a+";"}var b=/\S/,c=/\"/g,d=/\n/g,e=/\r/g,f=/\\/g,g={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};a.scan=function(c,d){function w(){p.length>0&&(q.push(new String(p)),p="")}function x(){var a=!0;for(var c=t;c<q.length;c++){a=q[c].tag&&g[q[c].tag]<g._v||!q[c].tag&&q[c].match(b)===null;if(!a)return!1}return a}function y(a,b){w();if(a&&x())for(var c=t,d;c<q.length;c++)q[c].tag||((d=q[c+1])&&d.tag==">"&&(d.indent=q[c].toString()),q.splice(c,1));else b||q.push({tag:"\n"});r=!1,t=q.length}function z(a,b){var c="="+v,d=a.indexOf(c,b),e=i(a.substring(a.indexOf("=",b)+1,d)).split(" ");return u=e[0],v=e[1],d+c.length-1}var e=c.length,f=0,k=1,l=2,m=f,n=null,o=null,p="",q=[],r=!1,s=0,t=0,u="{{",v="}}";d&&(d=d.split(" "),u=d[0],v=d[1]);for(s=0;s<e;s++)m==f?j(u,c,s)?(--s,w(),m=k):c.charAt(s)=="\n"?y(r):p+=c.charAt(s):m==k?(s+=u.length-1,o=g[c.charAt(s+1)],n=o?c.charAt(s+1):"_v",n=="="?(s=z(c,s),m=f):(o&&s++,m=l),r=s):j(v,c,s)?(q.push({tag:n,n:i(p),otag:u,ctag:v,i:n=="/"?r-v.length:s+u.length}),p="",s+=v.length-1,m=f,n=="{"&&(v=="}}"?s++:h(q[q.length-1]))):p+=c.charAt(s);return y(r,!0),q},a.generate=function(b,c,d){return d.asString?"function(c,p,i){"+b+";}":new a.Template(new Function("c","p","i",b),c,a)},a.parse=function(a,b){return b=b||{},k(a,"",[],b.sectionTags||[])},a.cache={},a.compile=function(a,b){b=b||{};var c=a+"||"+!!b.asString,d=this.cache[c];return d?d:(d=this.generate(n(this.parse(this.scan(a,b.delimiters),b)),a,b),this.cache[c]=d)}}(typeof exports!="undefined"?exports:Hogan),typeof module!="undefined"&&module.exports&&(module.exports=Hogan)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve Copyright 2012 Twitter, Inc.
|
3
|
+
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
|
4
|
+
*/
|
5
|
+
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&").replace(c,"<").replace(d,">").replace(e,"'").replace(f,"""):a}a.Template=function j(a,b,c){a&&(this.r=a),this.c=c,this.text=b||""},a.Template.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.ri([b],c||{},d)},ri:function(a,b,c){return this.r(a,b,c)},rp:function(a,b,c,d){var e=c[a];return e?(this.c&&typeof e=="string"&&(e=this.c.compile(e)),e.ri(b,c,d)):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);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,g){var h;return i(a)&&a.length===0?!1:(typeof a=="function"&&(a=this.ls(a,b,c,d,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];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,e){var f=this.c,g=a.call(b,d,function(a){return f.compile(a,{delimiters:e}).render(b,c)}),h=f.compile(g.toString(),{delimiters:e}).render(b,c);return this.b=h,!1},b:"",ls:function(a,b,c,d,e,f,g){var h=b[b.length-1],i=null;if(!d&&this.c&&a.length>0)return this.ho(a,h,c,this.text.substring(e,f),g);i=a.call(h);if(typeof i=="function"){if(d)return!0;if(this.c)return this.ho(i,h,c,this.text.substring(e,f),g)}return i},lv:function(a,b,c){var d=b[b.length-1],e=a.call(d);return typeof e=="function"&&(e=e.call(d)),e=e.toString(),this.c&&~e.indexOf("{{")?this.c.compile(e).render(d,c):e}};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]"}})(typeof exports!="undefined"?exports:Hogan),function(a){function h(a){a.n.substr(a.n.length-1)==="}"&&(a.n=a.n.substring(0,a.n.length-1))}function i(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function j(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function k(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||l(g,d))c.push(g),g.nodes=k(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!m(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function l(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function m(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 n(a){return'i = i || "";var b = i + "";var _ = this;'+q(a)+"return b;"}function o(a){return a.replace(f,"\\\\").replace(c,'\\"').replace(d,"\\n").replace(e,"\\r")}function p(a){return~a.indexOf(".")?"d":"f"}function q(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=r(a[c].nodes,a[c].n,p(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=s(a[c].nodes,a[c].n,p(a[c].n)):e=="<"||e==">"?b+=t(a[c]):e=="{"||e=="&"?b+=u(a[c].n,p(a[c].n)):e=="\n"?b+=w('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=v(a[c].n,p(a[c].n)):e===undefined&&(b+=w('"'+o(a[c])+'"'))}return b}function r(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+o(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+q(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function s(a,b,c){return"if (!_.s(_."+c+'("'+o(b)+'",c,p,1),c,p,1,0,0,"")){'+q(a)+"};"}function t(a){return'b += _.rp("'+o(a.n)+'",c,p,"'+(a.indent||"")+'");'}function u(a,b){return"b += (_."+b+'("'+o(a)+'",c,p,0));'}function v(a,b){return"b += (_.v(_."+b+'("'+o(a)+'",c,p,0)));'}function w(a){return"b += "+a+";"}var b=/\S/,c=/\"/g,d=/\n/g,e=/\r/g,f=/\\/g,g={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};a.scan=function(c,d){function w(){p.length>0&&(q.push(new String(p)),p="")}function x(){var a=!0;for(var c=t;c<q.length;c++){a=q[c].tag&&g[q[c].tag]<g._v||!q[c].tag&&q[c].match(b)===null;if(!a)return!1}return a}function y(a,b){w();if(a&&x())for(var c=t,d;c<q.length;c++)q[c].tag||((d=q[c+1])&&d.tag==">"&&(d.indent=q[c].toString()),q.splice(c,1));else b||q.push({tag:"\n"});r=!1,t=q.length}function z(a,b){var c="="+v,d=a.indexOf(c,b),e=i(a.substring(a.indexOf("=",b)+1,d)).split(" ");return u=e[0],v=e[1],d+c.length-1}var e=c.length,f=0,k=1,l=2,m=f,n=null,o=null,p="",q=[],r=!1,s=0,t=0,u="{{",v="}}";d&&(d=d.split(" "),u=d[0],v=d[1]);for(s=0;s<e;s++)m==f?j(u,c,s)?(--s,w(),m=k):c.charAt(s)=="\n"?y(r):p+=c.charAt(s):m==k?(s+=u.length-1,o=g[c.charAt(s+1)],n=o?c.charAt(s+1):"_v",n=="="?(s=z(c,s),m=f):(o&&s++,m=l),r=s):j(v,c,s)?(q.push({tag:n,n:i(p),otag:u,ctag:v,i:n=="/"?r-v.length:s+u.length}),p="",s+=v.length-1,m=f,n=="{"&&(v=="}}"?s++:h(q[q.length-1]))):p+=c.charAt(s);return y(r,!0),q},a.generate=function(b,c,d){return d.asString?"function(c,p,i){"+b+";}":new a.Template(new Function("c","p","i",b),c,a)},a.parse=function(a,b){return b=b||{},k(a,"",[],b.sectionTags||[])},a.cache={},a.compile=function(a,b){b=b||{};var c=a+"||"+!!b.asString,d=this.cache[c];return d?d:(d=this.generate(n(this.parse(this.scan(a,b.delimiters),b)),a,b),this.cache[c]=d)}}(typeof exports!="undefined"?exports:Hogan)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve Copyright 2012 Twitter, Inc.
|
3
|
+
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
|
4
|
+
*/
|
5
|
+
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&").replace(c,"<").replace(d,">").replace(e,"'").replace(f,"""):a}a.Template=function j(a,b,c){a&&(this.r=a),this.c=c,this.text=b||""},a.Template.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.ri([b],c||{},d)},ri:function(a,b,c){return this.r(a,b,c)},rp:function(a,b,c,d){var e=c[a];return e?(this.c&&typeof e=="string"&&(e=this.c.compile(e)),e.ri(b,c,d)):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);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,g){var h;return i(a)&&a.length===0?!1:(typeof a=="function"&&(a=this.ls(a,b,c,d,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];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,e){var f=this.c,g=a.call(b,d,function(a){return f.compile(a,{delimiters:e}).render(b,c)}),h=f.compile(g.toString(),{delimiters:e}).render(b,c);return this.b=h,!1},b:"",ls:function(a,b,c,d,e,f,g){var h=b[b.length-1],i=null;if(!d&&this.c&&a.length>0)return this.ho(a,h,c,this.text.substring(e,f),g);i=a.call(h);if(typeof i=="function"){if(d)return!0;if(this.c)return this.ho(i,h,c,this.text.substring(e,f),g)}return i},lv:function(a,b,c){var d=b[b.length-1],e=a.call(d);return typeof e=="function"&&(e=e.call(d)),e=e.toString(),this.c&&~e.indexOf("{{")?this.c.compile(e).render(d,c):e}};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]"}})(typeof exports!="undefined"?exports:Hogan),function(a){function h(a){a.n.substr(a.n.length-1)==="}"&&(a.n=a.n.substring(0,a.n.length-1))}function i(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function j(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function k(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||l(g,d))c.push(g),g.nodes=k(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!m(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function l(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function m(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 n(a){return'i = i || "";var b = i + "";var _ = this;'+q(a)+"return b;"}function o(a){return a.replace(f,"\\\\").replace(c,'\\"').replace(d,"\\n").replace(e,"\\r")}function p(a){return~a.indexOf(".")?"d":"f"}function q(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=r(a[c].nodes,a[c].n,p(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=s(a[c].nodes,a[c].n,p(a[c].n)):e=="<"||e==">"?b+=t(a[c]):e=="{"||e=="&"?b+=u(a[c].n,p(a[c].n)):e=="\n"?b+=w('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=v(a[c].n,p(a[c].n)):e===undefined&&(b+=w('"'+o(a[c])+'"'))}return b}function r(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+o(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+q(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function s(a,b,c){return"if (!_.s(_."+c+'("'+o(b)+'",c,p,1),c,p,1,0,0,"")){'+q(a)+"};"}function t(a){return'b += _.rp("'+o(a.n)+'",c,p,"'+(a.indent||"")+'");'}function u(a,b){return"b += (_."+b+'("'+o(a)+'",c,p,0));'}function v(a,b){return"b += (_.v(_."+b+'("'+o(a)+'",c,p,0)));'}function w(a){return"b += "+a+";"}var b=/\S/,c=/\"/g,d=/\n/g,e=/\r/g,f=/\\/g,g={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};a.scan=function(c,d){function w(){p.length>0&&(q.push(new String(p)),p="")}function x(){var a=!0;for(var c=t;c<q.length;c++){a=q[c].tag&&g[q[c].tag]<g._v||!q[c].tag&&q[c].match(b)===null;if(!a)return!1}return a}function y(a,b){w();if(a&&x())for(var c=t,d;c<q.length;c++)q[c].tag||((d=q[c+1])&&d.tag==">"&&(d.indent=q[c].toString()),q.splice(c,1));else b||q.push({tag:"\n"});r=!1,t=q.length}function z(a,b){var c="="+v,d=a.indexOf(c,b),e=i(a.substring(a.indexOf("=",b)+1,d)).split(" ");return u=e[0],v=e[1],d+c.length-1}var e=c.length,f=0,k=1,l=2,m=f,n=null,o=null,p="",q=[],r=!1,s=0,t=0,u="{{",v="}}";d&&(d=d.split(" "),u=d[0],v=d[1]);for(s=0;s<e;s++)m==f?j(u,c,s)?(--s,w(),m=k):c.charAt(s)=="\n"?y(r):p+=c.charAt(s):m==k?(s+=u.length-1,o=g[c.charAt(s+1)],n=o?c.charAt(s+1):"_v",n=="="?(s=z(c,s),m=f):(o&&s++,m=l),r=s):j(v,c,s)?(q.push({tag:n,n:i(p),otag:u,ctag:v,i:n=="/"?r-v.length:s+u.length}),p="",s+=v.length-1,m=f,n=="{"&&(v=="}}"?s++:h(q[q.length-1]))):p+=c.charAt(s);return y(r,!0),q},a.generate=function(b,c,d){return d.asString?"function(c,p,i){"+b+";}":new a.Template(new Function("c","p","i",b),c,a)},a.parse=function(a,b){return b=b||{},k(a,"",[],b.sectionTags||[])},a.cache={},a.compile=function(a,b){b=b||{};var c=a+"||"+!!b.asString,d=this.cache[c];return d?d:(d=this.generate(n(this.parse(this.scan(a,b.delimiters),b)),a,b),this.cache[c]=d)}}(typeof exports!="undefined"?exports:Hogan);var Mustache=function(a){function b(b,c,d,e){var f=this.f(b,c,d,0),g=c;return f&&(g=g.concat(f)),a.Template.prototype.rp.call(this,b,g,d,e)}var c=function(c,d,e){this.rp=b,a.Template.call(this,c,d,e)};c.prototype=a.Template.prototype;var d,e=function(){this.cache={},this.generate=function(a,b,e){return new c(new Function("c","p","i",a),b,d)}};return e.prototype=a,d=new e,{to_html:function(a,b,c,e){var f=d.compile(a),g=f.render(b,c);if(!e)return g;e(g)}}}(Hogan)
|
@@ -0,0 +1,619 @@
|
|
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
|
+
// A wrapper for compatibility with Mustache.js, quirks and all
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
var Hogan = {};
|
21
|
+
|
22
|
+
(function (Hogan) {
|
23
|
+
Hogan.Template = function constructor(renderFunc, text, compiler) {
|
24
|
+
if (renderFunc) {
|
25
|
+
this.r = renderFunc;
|
26
|
+
}
|
27
|
+
this.c = compiler;
|
28
|
+
this.text = text || '';
|
29
|
+
}
|
30
|
+
|
31
|
+
Hogan.Template.prototype = {
|
32
|
+
// render: replaced by generated code.
|
33
|
+
r: function (context, partials, indent) { return ''; },
|
34
|
+
|
35
|
+
// variable escaping
|
36
|
+
v: hoganEscape,
|
37
|
+
|
38
|
+
render: function render(context, partials, indent) {
|
39
|
+
return this.ri([context], partials || {}, indent);
|
40
|
+
},
|
41
|
+
|
42
|
+
// render internal -- a hook for overrides that catches partials too
|
43
|
+
ri: function (context, partials, indent) {
|
44
|
+
return this.r(context, partials, indent);
|
45
|
+
},
|
46
|
+
|
47
|
+
// tries to find a partial in the curent scope and render it
|
48
|
+
rp: function(name, context, partials, indent) {
|
49
|
+
var partial = partials[name];
|
50
|
+
|
51
|
+
if (!partial) {
|
52
|
+
return '';
|
53
|
+
}
|
54
|
+
|
55
|
+
if (this.c && typeof partial == 'string') {
|
56
|
+
partial = this.c.compile(partial);
|
57
|
+
}
|
58
|
+
|
59
|
+
return partial.ri(context, partials, indent);
|
60
|
+
},
|
61
|
+
|
62
|
+
// render a section
|
63
|
+
rs: function(context, partials, section) {
|
64
|
+
var buf = '',
|
65
|
+
tail = context[context.length - 1];
|
66
|
+
|
67
|
+
if (!isArray(tail)) {
|
68
|
+
return buf = section(context, partials);
|
69
|
+
}
|
70
|
+
|
71
|
+
for (var i = 0; i < tail.length; i++) {
|
72
|
+
context.push(tail[i]);
|
73
|
+
buf += section(context, partials);
|
74
|
+
context.pop();
|
75
|
+
}
|
76
|
+
|
77
|
+
return buf;
|
78
|
+
},
|
79
|
+
|
80
|
+
// maybe start a section
|
81
|
+
s: function(val, ctx, partials, inverted, start, end, tags) {
|
82
|
+
var pass;
|
83
|
+
|
84
|
+
if (isArray(val) && val.length === 0) {
|
85
|
+
return false;
|
86
|
+
}
|
87
|
+
|
88
|
+
if (typeof val == 'function') {
|
89
|
+
val = this.ls(val, ctx, partials, inverted, start, end, tags);
|
90
|
+
}
|
91
|
+
|
92
|
+
pass = (val === '') || !!val;
|
93
|
+
|
94
|
+
if (!inverted && pass && ctx) {
|
95
|
+
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
|
96
|
+
}
|
97
|
+
|
98
|
+
return pass;
|
99
|
+
},
|
100
|
+
|
101
|
+
// find values with dotted names
|
102
|
+
d: function(key, ctx, partials, returnFound) {
|
103
|
+
var names = key.split('.'),
|
104
|
+
val = this.f(names[0], ctx, partials, returnFound),
|
105
|
+
cx = null;
|
106
|
+
|
107
|
+
if (key === '.' && isArray(ctx[ctx.length - 2])) {
|
108
|
+
return ctx[ctx.length - 1];
|
109
|
+
}
|
110
|
+
|
111
|
+
for (var i = 1; i < names.length; i++) {
|
112
|
+
if (val && typeof val == 'object' && names[i] in val) {
|
113
|
+
cx = val;
|
114
|
+
val = val[names[i]];
|
115
|
+
} else {
|
116
|
+
val = '';
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
if (returnFound && !val) {
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (!returnFound && typeof val == 'function') {
|
125
|
+
ctx.push(cx);
|
126
|
+
val = this.lv(val, ctx, partials);
|
127
|
+
ctx.pop();
|
128
|
+
}
|
129
|
+
|
130
|
+
return val;
|
131
|
+
},
|
132
|
+
|
133
|
+
// find values with normal names
|
134
|
+
f: function(key, ctx, partials, returnFound) {
|
135
|
+
var val = false,
|
136
|
+
v = null,
|
137
|
+
found = false;
|
138
|
+
|
139
|
+
for (var i = ctx.length - 1; i >= 0; i--) {
|
140
|
+
v = ctx[i];
|
141
|
+
if (v && typeof v == 'object' && key in v) {
|
142
|
+
val = v[key];
|
143
|
+
found = true;
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
if (!found) {
|
149
|
+
return (returnFound) ? false : "";
|
150
|
+
}
|
151
|
+
|
152
|
+
if (!returnFound && typeof val == 'function') {
|
153
|
+
val = this.lv(val, ctx, partials);
|
154
|
+
}
|
155
|
+
|
156
|
+
return val;
|
157
|
+
},
|
158
|
+
|
159
|
+
// higher order templates
|
160
|
+
ho: function(val, cx, partials, text, tags) {
|
161
|
+
var compiler = this.c;
|
162
|
+
var t = val.call(cx, text, function(t) {
|
163
|
+
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
|
164
|
+
});
|
165
|
+
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
|
166
|
+
this.b = s;
|
167
|
+
return false;
|
168
|
+
},
|
169
|
+
|
170
|
+
// higher order template result buffer
|
171
|
+
b: '',
|
172
|
+
|
173
|
+
// lambda replace section
|
174
|
+
ls: function(val, ctx, partials, inverted, start, end, tags) {
|
175
|
+
var cx = ctx[ctx.length - 1],
|
176
|
+
t = null;
|
177
|
+
|
178
|
+
if (!inverted && this.c && val.length > 0) {
|
179
|
+
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
|
180
|
+
}
|
181
|
+
|
182
|
+
t = val.call(cx);
|
183
|
+
|
184
|
+
if (typeof t == 'function') {
|
185
|
+
if (inverted) {
|
186
|
+
return true;
|
187
|
+
} else if (this.c) {
|
188
|
+
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
return t;
|
193
|
+
},
|
194
|
+
|
195
|
+
// lambda replace variable
|
196
|
+
lv: function(val, ctx, partials) {
|
197
|
+
var cx = ctx[ctx.length - 1];
|
198
|
+
var result = val.call(cx);
|
199
|
+
if (typeof result == 'function') {
|
200
|
+
result = result.call(cx);
|
201
|
+
}
|
202
|
+
result = result.toString();
|
203
|
+
|
204
|
+
if (this.c && ~result.indexOf("{{")) {
|
205
|
+
return this.c.compile(result).render(cx, partials);
|
206
|
+
}
|
207
|
+
|
208
|
+
return result;
|
209
|
+
}
|
210
|
+
|
211
|
+
};
|
212
|
+
|
213
|
+
var rAmp = /&/g,
|
214
|
+
rLt = /</g,
|
215
|
+
rGt = />/g,
|
216
|
+
rApos =/\'/g,
|
217
|
+
rQuot = /\"/g,
|
218
|
+
hChars =/[&<>\"\']/;
|
219
|
+
|
220
|
+
function hoganEscape(str) {
|
221
|
+
str = String((str === null || str === undefined) ? '' : str);
|
222
|
+
return hChars.test(str) ?
|
223
|
+
str
|
224
|
+
.replace(rAmp,'&')
|
225
|
+
.replace(rLt,'<')
|
226
|
+
.replace(rGt,'>')
|
227
|
+
.replace(rApos,''')
|
228
|
+
.replace(rQuot, '"') :
|
229
|
+
str;
|
230
|
+
}
|
231
|
+
|
232
|
+
var isArray = Array.isArray || function(a) {
|
233
|
+
return Object.prototype.toString.call(a) === '[object Array]';
|
234
|
+
};
|
235
|
+
|
236
|
+
})(typeof exports !== 'undefined' ? exports : Hogan);
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
(function (Hogan) {
|
242
|
+
// Setup regex assignments
|
243
|
+
// remove whitespace according to Mustache spec
|
244
|
+
var rIsWhitespace = /\S/,
|
245
|
+
rQuot = /\"/g,
|
246
|
+
rNewline = /\n/g,
|
247
|
+
rCr = /\r/g,
|
248
|
+
rSlash = /\\/g,
|
249
|
+
tagTypes = {
|
250
|
+
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
|
251
|
+
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
|
252
|
+
};
|
253
|
+
|
254
|
+
Hogan.scan = function scan(text, delimiters) {
|
255
|
+
var len = text.length,
|
256
|
+
IN_TEXT = 0,
|
257
|
+
IN_TAG_TYPE = 1,
|
258
|
+
IN_TAG = 2,
|
259
|
+
state = IN_TEXT,
|
260
|
+
tagType = null,
|
261
|
+
tag = null,
|
262
|
+
buf = '',
|
263
|
+
tokens = [],
|
264
|
+
seenTag = false,
|
265
|
+
i = 0,
|
266
|
+
lineStart = 0,
|
267
|
+
otag = '{{',
|
268
|
+
ctag = '}}';
|
269
|
+
|
270
|
+
function addBuf() {
|
271
|
+
if (buf.length > 0) {
|
272
|
+
tokens.push(new String(buf));
|
273
|
+
buf = '';
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
function lineIsWhitespace() {
|
278
|
+
var isAllWhitespace = true;
|
279
|
+
for (var j = lineStart; j < tokens.length; j++) {
|
280
|
+
isAllWhitespace =
|
281
|
+
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
|
282
|
+
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
|
283
|
+
if (!isAllWhitespace) {
|
284
|
+
return false;
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
return isAllWhitespace;
|
289
|
+
}
|
290
|
+
|
291
|
+
function filterLine(haveSeenTag, noNewLine) {
|
292
|
+
addBuf();
|
293
|
+
|
294
|
+
if (haveSeenTag && lineIsWhitespace()) {
|
295
|
+
for (var j = lineStart, next; j < tokens.length; j++) {
|
296
|
+
if (!tokens[j].tag) {
|
297
|
+
if ((next = tokens[j+1]) && next.tag == '>') {
|
298
|
+
// set indent to token value
|
299
|
+
next.indent = tokens[j].toString()
|
300
|
+
}
|
301
|
+
tokens.splice(j, 1);
|
302
|
+
}
|
303
|
+
}
|
304
|
+
} else if (!noNewLine) {
|
305
|
+
tokens.push({tag:'\n'});
|
306
|
+
}
|
307
|
+
|
308
|
+
seenTag = false;
|
309
|
+
lineStart = tokens.length;
|
310
|
+
}
|
311
|
+
|
312
|
+
function changeDelimiters(text, index) {
|
313
|
+
var close = '=' + ctag,
|
314
|
+
closeIndex = text.indexOf(close, index),
|
315
|
+
delimiters = trim(
|
316
|
+
text.substring(text.indexOf('=', index) + 1, closeIndex)
|
317
|
+
).split(' ');
|
318
|
+
|
319
|
+
otag = delimiters[0];
|
320
|
+
ctag = delimiters[1];
|
321
|
+
|
322
|
+
return closeIndex + close.length - 1;
|
323
|
+
}
|
324
|
+
|
325
|
+
if (delimiters) {
|
326
|
+
delimiters = delimiters.split(' ');
|
327
|
+
otag = delimiters[0];
|
328
|
+
ctag = delimiters[1];
|
329
|
+
}
|
330
|
+
|
331
|
+
for (i = 0; i < len; i++) {
|
332
|
+
if (state == IN_TEXT) {
|
333
|
+
if (tagChange(otag, text, i)) {
|
334
|
+
--i;
|
335
|
+
addBuf();
|
336
|
+
state = IN_TAG_TYPE;
|
337
|
+
} else {
|
338
|
+
if (text.charAt(i) == '\n') {
|
339
|
+
filterLine(seenTag);
|
340
|
+
} else {
|
341
|
+
buf += text.charAt(i);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
} else if (state == IN_TAG_TYPE) {
|
345
|
+
i += otag.length - 1;
|
346
|
+
tag = tagTypes[text.charAt(i + 1)];
|
347
|
+
tagType = tag ? text.charAt(i + 1) : '_v';
|
348
|
+
if (tagType == '=') {
|
349
|
+
i = changeDelimiters(text, i);
|
350
|
+
state = IN_TEXT;
|
351
|
+
} else {
|
352
|
+
if (tag) {
|
353
|
+
i++;
|
354
|
+
}
|
355
|
+
state = IN_TAG;
|
356
|
+
}
|
357
|
+
seenTag = i;
|
358
|
+
} else {
|
359
|
+
if (tagChange(ctag, text, i)) {
|
360
|
+
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
|
361
|
+
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
|
362
|
+
buf = '';
|
363
|
+
i += ctag.length - 1;
|
364
|
+
state = IN_TEXT;
|
365
|
+
if (tagType == '{') {
|
366
|
+
if (ctag == '}}') {
|
367
|
+
i++;
|
368
|
+
} else {
|
369
|
+
cleanTripleStache(tokens[tokens.length - 1]);
|
370
|
+
}
|
371
|
+
}
|
372
|
+
} else {
|
373
|
+
buf += text.charAt(i);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
filterLine(seenTag, true);
|
379
|
+
|
380
|
+
return tokens;
|
381
|
+
}
|
382
|
+
|
383
|
+
function cleanTripleStache(token) {
|
384
|
+
if (token.n.substr(token.n.length - 1) === '}') {
|
385
|
+
token.n = token.n.substring(0, token.n.length - 1);
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
function trim(s) {
|
390
|
+
if (s.trim) {
|
391
|
+
return s.trim();
|
392
|
+
}
|
393
|
+
|
394
|
+
return s.replace(/^\s*|\s*$/g, '');
|
395
|
+
}
|
396
|
+
|
397
|
+
function tagChange(tag, text, index) {
|
398
|
+
if (text.charAt(index) != tag.charAt(0)) {
|
399
|
+
return false;
|
400
|
+
}
|
401
|
+
|
402
|
+
for (var i = 1, l = tag.length; i < l; i++) {
|
403
|
+
if (text.charAt(index + i) != tag.charAt(i)) {
|
404
|
+
return false;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
return true;
|
409
|
+
}
|
410
|
+
|
411
|
+
function buildTree(tokens, kind, stack, customTags) {
|
412
|
+
var instructions = [],
|
413
|
+
opener = null,
|
414
|
+
token = null;
|
415
|
+
|
416
|
+
while (tokens.length > 0) {
|
417
|
+
token = tokens.shift();
|
418
|
+
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
|
419
|
+
stack.push(token);
|
420
|
+
token.nodes = buildTree(tokens, token.tag, stack, customTags);
|
421
|
+
instructions.push(token);
|
422
|
+
} else if (token.tag == '/') {
|
423
|
+
if (stack.length === 0) {
|
424
|
+
throw new Error('Closing tag without opener: /' + token.n);
|
425
|
+
}
|
426
|
+
opener = stack.pop();
|
427
|
+
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
|
428
|
+
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
|
429
|
+
}
|
430
|
+
opener.end = token.i;
|
431
|
+
return instructions;
|
432
|
+
} else {
|
433
|
+
instructions.push(token);
|
434
|
+
}
|
435
|
+
}
|
436
|
+
|
437
|
+
if (stack.length > 0) {
|
438
|
+
throw new Error('missing closing tag: ' + stack.pop().n);
|
439
|
+
}
|
440
|
+
|
441
|
+
return instructions;
|
442
|
+
}
|
443
|
+
|
444
|
+
function isOpener(token, tags) {
|
445
|
+
for (var i = 0, l = tags.length; i < l; i++) {
|
446
|
+
if (tags[i].o == token.n) {
|
447
|
+
token.tag = '#';
|
448
|
+
return true;
|
449
|
+
}
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
function isCloser(close, open, tags) {
|
454
|
+
for (var i = 0, l = tags.length; i < l; i++) {
|
455
|
+
if (tags[i].c == close && tags[i].o == open) {
|
456
|
+
return true;
|
457
|
+
}
|
458
|
+
}
|
459
|
+
}
|
460
|
+
|
461
|
+
function writeCode(tree) {
|
462
|
+
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
|
463
|
+
}
|
464
|
+
|
465
|
+
Hogan.generate = function (code, text, options) {
|
466
|
+
if (options.asString) {
|
467
|
+
return 'function(c,p,i){' + code + ';}';
|
468
|
+
}
|
469
|
+
|
470
|
+
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
|
471
|
+
}
|
472
|
+
|
473
|
+
function esc(s) {
|
474
|
+
return s.replace(rSlash, '\\\\')
|
475
|
+
.replace(rQuot, '\\\"')
|
476
|
+
.replace(rNewline, '\\n')
|
477
|
+
.replace(rCr, '\\r');
|
478
|
+
}
|
479
|
+
|
480
|
+
function chooseMethod(s) {
|
481
|
+
return (~s.indexOf('.')) ? 'd' : 'f';
|
482
|
+
}
|
483
|
+
|
484
|
+
function walk(tree) {
|
485
|
+
var code = '';
|
486
|
+
for (var i = 0, l = tree.length; i < l; i++) {
|
487
|
+
var tag = tree[i].tag;
|
488
|
+
if (tag == '#') {
|
489
|
+
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
|
490
|
+
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
|
491
|
+
} else if (tag == '^') {
|
492
|
+
code += invertedSection(tree[i].nodes, tree[i].n,
|
493
|
+
chooseMethod(tree[i].n));
|
494
|
+
} else if (tag == '<' || tag == '>') {
|
495
|
+
code += partial(tree[i]);
|
496
|
+
} else if (tag == '{' || tag == '&') {
|
497
|
+
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
|
498
|
+
} else if (tag == '\n') {
|
499
|
+
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
|
500
|
+
} else if (tag == '_v') {
|
501
|
+
code += variable(tree[i].n, chooseMethod(tree[i].n));
|
502
|
+
} else if (tag === undefined) {
|
503
|
+
code += text('"' + esc(tree[i]) + '"');
|
504
|
+
}
|
505
|
+
}
|
506
|
+
return code;
|
507
|
+
}
|
508
|
+
|
509
|
+
function section(nodes, id, method, start, end, tags) {
|
510
|
+
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
|
511
|
+
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
|
512
|
+
'b += _.rs(c,p,' +
|
513
|
+
'function(c,p){ var b = "";' +
|
514
|
+
walk(nodes) +
|
515
|
+
'return b;});c.pop();}' +
|
516
|
+
'else{b += _.b; _.b = ""};';
|
517
|
+
}
|
518
|
+
|
519
|
+
function invertedSection(nodes, id, method) {
|
520
|
+
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
|
521
|
+
walk(nodes) +
|
522
|
+
'};';
|
523
|
+
}
|
524
|
+
|
525
|
+
function partial(tok) {
|
526
|
+
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
|
527
|
+
}
|
528
|
+
|
529
|
+
function tripleStache(id, method) {
|
530
|
+
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
|
531
|
+
}
|
532
|
+
|
533
|
+
function variable(id, method) {
|
534
|
+
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
|
535
|
+
}
|
536
|
+
|
537
|
+
function text(id) {
|
538
|
+
return 'b += ' + id + ';';
|
539
|
+
}
|
540
|
+
|
541
|
+
Hogan.parse = function(tokens, options) {
|
542
|
+
options = options || {};
|
543
|
+
return buildTree(tokens, '', [], options.sectionTags || []);
|
544
|
+
},
|
545
|
+
|
546
|
+
Hogan.cache = {};
|
547
|
+
|
548
|
+
Hogan.compile = function(text, options) {
|
549
|
+
// options
|
550
|
+
//
|
551
|
+
// asString: false (default)
|
552
|
+
//
|
553
|
+
// sectionTags: [{o: '_foo', c: 'foo'}]
|
554
|
+
// An array of object with o and c fields that indicate names for custom
|
555
|
+
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
|
556
|
+
//
|
557
|
+
// delimiters: A string that overrides the default delimiters.
|
558
|
+
// Example: "<% %>"
|
559
|
+
//
|
560
|
+
options = options || {};
|
561
|
+
|
562
|
+
var key = text + '||' + !!options.asString;
|
563
|
+
|
564
|
+
var t = this.cache[key];
|
565
|
+
|
566
|
+
if (t) {
|
567
|
+
return t;
|
568
|
+
}
|
569
|
+
|
570
|
+
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
|
571
|
+
return this.cache[key] = t;
|
572
|
+
};
|
573
|
+
})(typeof exports !== 'undefined' ? exports : Hogan);
|
574
|
+
|
575
|
+
|
576
|
+
var Mustache = (function (Hogan) {
|
577
|
+
|
578
|
+
// Mustache.js has non-spec partial context behavior
|
579
|
+
function mustachePartial(name, context, partials, indent) {
|
580
|
+
var partialScope = this.f(name, context, partials, 0);
|
581
|
+
var cx = context;
|
582
|
+
if (partialScope) {
|
583
|
+
cx = cx.concat(partialScope);
|
584
|
+
}
|
585
|
+
|
586
|
+
return Hogan.Template.prototype.rp.call(this, name, cx, partials, indent);
|
587
|
+
}
|
588
|
+
|
589
|
+
var HoganTemplateWrapper = function(renderFunc, text, compiler){
|
590
|
+
this.rp = mustachePartial;
|
591
|
+
Hogan.Template.call(this, renderFunc, text, compiler);
|
592
|
+
};
|
593
|
+
HoganTemplateWrapper.prototype = Hogan.Template.prototype;
|
594
|
+
|
595
|
+
// Add a wrapper for Hogan's generate method. Mustache and Hogan keep
|
596
|
+
// separate caches, and Mustache returns wrapped templates.
|
597
|
+
var wrapper;
|
598
|
+
var HoganWrapper = function(){
|
599
|
+
this.cache = {};
|
600
|
+
this.generate = function(code, text, options) {
|
601
|
+
return new HoganTemplateWrapper(new Function('c', 'p', 'i', code), text, wrapper);
|
602
|
+
}
|
603
|
+
};
|
604
|
+
HoganWrapper.prototype = Hogan;
|
605
|
+
wrapper = new HoganWrapper();
|
606
|
+
|
607
|
+
return {
|
608
|
+
to_html: function(text, data, partials, sendFun) {
|
609
|
+
var template = wrapper.compile(text);
|
610
|
+
var result = template.render(data, partials);
|
611
|
+
if (!sendFun) {
|
612
|
+
return result;
|
613
|
+
}
|
614
|
+
|
615
|
+
sendFun(result);
|
616
|
+
}
|
617
|
+
}
|
618
|
+
|
619
|
+
})(Hogan);
|