0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-18 15:54:26 +01:00

Merge branch 'bs3_jekyll' into 3.0.0-wip

Conflicts:
	docs/css.html
	docs/templates/pages/css.mustache
This commit is contained in:
Mark Otto 2013-02-14 23:42:47 -08:00
commit ae525258af
111 changed files with 2423 additions and 19166 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Ignore compiled docs
_gh_pages
# Numerous always-ignore extensions
*.diff
*.err

View File

@ -1,39 +1,36 @@
BOOTSTRAP = ./docs/assets/css/bootstrap.css
BOOTSTRAP_LESS = ./less/bootstrap.less
DATE=$(shell date +%I:%M%p)
CHECK=\033[32m✔\033[39m
HR=\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
CHECK=\033[32m✔ Done\033[39m
HR=\033[37m--------------------------------------------------\033[39m
#
# BUILD DOCS
#
build:
@echo "\n${HR}"
@echo "Building Bootstrap..."
@echo "${HR}\n"
@echo "\n\n"
@echo "\033[36mBuilding Bootstrap...\033[39m"
@echo "${HR}"
@jshint js/*.js --config js/.jshintrc
@jshint js/tests/unit/*.js --config js/.jshintrc
@echo "Running JSHint on javascript... ${CHECK} Done"
@echo "Running JSHint on javascript... ${CHECK}"
@./node_modules/.bin/recess --compile ${BOOTSTRAP_LESS} > ${BOOTSTRAP}
@echo "Compiling LESS with Recess... ${CHECK} Done"
@node docs/build
@echo "Compiling LESS with Recess... ${CHECK}"
@cp fonts/* docs/assets/fonts/
@cp js/*.js docs/assets/js/
@cp js/tests/vendor/jquery.js docs/assets/js/
@echo "Compiling documentation... ${CHECK} Done"
@echo "Prepping fonts and JavaScript... ${CHECK}"
@cat js/bootstrap-transition.js js/bootstrap-alert.js js/bootstrap-button.js js/bootstrap-carousel.js js/bootstrap-collapse.js js/bootstrap-dropdown.js js/bootstrap-modal.js js/bootstrap-tooltip.js js/bootstrap-popover.js js/bootstrap-scrollspy.js js/bootstrap-tab.js js/bootstrap-typeahead.js js/bootstrap-affix.js > docs/assets/js/bootstrap.js
@./node_modules/.bin/uglifyjs -nc docs/assets/js/bootstrap.js > docs/assets/js/bootstrap.min.tmp.js
@echo "/**\n* Bootstrap.js v3.0.0 by @fat & @mdo\n* Copyright 2012 Twitter, Inc.\n* http://www.apache.org/licenses/LICENSE-2.0.txt\n*/" > docs/assets/js/copyright.js
@cat docs/assets/js/copyright.js docs/assets/js/bootstrap.min.tmp.js > docs/assets/js/bootstrap.min.js
@rm docs/assets/js/copyright.js docs/assets/js/bootstrap.min.tmp.js
@echo "Compiling and minifying javascript... ${CHECK} Done"
@echo "\n${HR}"
@echo "Bootstrap successfully built at ${DATE}."
@echo "${HR}\n"
@echo "Thanks for using Bootstrap,"
@echo "<3 @mdo and @fat\n"
@echo "Compiling and minifying javascript... ${CHECK}"
@echo "${HR}"
@echo "\033[36mSuccess!\n\033[39m"
@echo "\033[37mThanks for using Bootstrap,"
@echo "<3 @mdo and @fat\n\033[39m"
#
# RUN JSHINT & QUNIT TESTS IN PHANTOMJS

View File

@ -2,7 +2,7 @@
<img src="http://twitter.github.com/bootstrap/assets/img/bootstrap-docs-readme.png" width="100px">
</a>
# [Bootstrap v3.0.0](http://twitter.github.com/bootstrap) [![Build Status](https://secure.travis-ci.org/twitter/bootstrap.png)](http://travis-ci.org/twitter/bootstrap)
# [Bootstrap v3.0.0](http://getbootstrap.com) [![Build Status](https://secure.travis-ci.org/twitter/bootstrap.png)](http://travis-ci.org/twitter/bootstrap)
Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and easier web development, created and maintained by [Mark Otto](http://twitter.com/mdo) and [Jacob Thornton](http://twitter.com/fat).
@ -18,6 +18,8 @@ Three quick start options are available:
* Clone the repo: `git clone git://github.com/twitter/bootstrap.git`.
* Install with Twitter's [Bower](http://twitter.github.com/bower): `bower install bootstrap`.
Read the [Getting Started page](http://getbootstrap.com/getting-started/) for information on the framework contents, basic template guidelines, and more.
## Versioning
@ -38,7 +40,7 @@ For more information on SemVer, please visit [http://semver.org/](http://semver.
## Bug tracker
## Bugs and feature requests
Have a bug or a feature request? [Please open a new issue](https://github.com/twitter/bootstrap/issues). Before opening any issue, please search for existing issues and read the [Issue Guidelines](https://github.com/necolas/issue-guidelines), written by [Nicolas Gallagher](https://github.com/necolas/).
@ -55,24 +57,31 @@ Keep track of development and community news.
## Developers
## Documentation
We have included a makefile with convenience methods for working with the Bootstrap library.
Bootstrap's docs are built using [Jekyll](http://jekyllrb.com) and hosted on GitHub Pages at [http://getbootstrap.com](http://getbootstrap.com). To view our docs locally, you'll need to [install Jekyll](https://github.com/mojombo/jekyll/wiki/install) to run a local server.
+ **dependencies**
Our makefile depends on you having recess, connect, uglify.js, and jshint installed. To install, just run the following command in npm:
Documentation for [previous versions](https://github.com/twitter/bootstrap/tags) is also available via tags.
## Compiling CSS and JavaScript
Bootstrap includes a makefile with convenient methods for working with the framework. Before getting started, be sure to install the necessary local dependencies:
```
$ npm install recess connect uglify-js jshint -g
$ npm install
```
+ **build** - `make`
Runs the recess compiler to rebuild the `/less` files and compiles the docs pages. Requires recess and uglify-js.
Once installed, you'll be able to run the various make commands provided:
+ **test** - `make test`
#### build - `make`
Runs the recess compiler to rebuild the `/less` files and compiles the docs. Requires recess and uglify-js.
#### test - `make test`
Runs jshint and qunit tests headlessly in [phantomjs](http://code.google.com/p/phantomjs/) (used for ci). Depends on having phantomjs installed.
+ **watch** - `make watch`
#### watch - `make watch`
This is a convenience method for watching just Less files and automatically building them whenever you save. Requires the Watchr gem.
@ -81,8 +90,6 @@ This is a convenience method for watching just Less files and automatically buil
Please submit all pull requests against *-wip branches. If your pull request contains JavaScript patches or features, you must include relevant unit tests. All HTML and CSS should conform to the [Code Guide](http://github.com/mdo/code-guide), maintained by [Mark Otto](http://github.com/mdo).
Thanks!
## Authors

13
_config.yml Normal file
View File

@ -0,0 +1,13 @@
# Dependencies
markdown: rdiscount
pygments: true
# Permalinks
permalink: pretty
# Server
auto: true
source: ./docs
destination: ./_gh_pages
url: http://bootstrap.dev:9001
server_port: 9001

View File

@ -0,0 +1,35 @@
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>

View File

@ -0,0 +1,39 @@
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/assets/js/jquery.js"></script>
<script src="/assets/js/bootstrap-transition.js"></script>
<script src="/assets/js/bootstrap-alert.js"></script>
<script src="/assets/js/bootstrap-modal.js"></script>
<script src="/assets/js/bootstrap-dropdown.js"></script>
<script src="/assets/js/bootstrap-scrollspy.js"></script>
<script src="/assets/js/bootstrap-tab.js"></script>
<script src="/assets/js/bootstrap-tooltip.js"></script>
<script src="/assets/js/bootstrap-popover.js"></script>
<script src="/assets/js/bootstrap-button.js"></script>
<script src="/assets/js/bootstrap-collapse.js"></script>
<script src="/assets/js/bootstrap-carousel.js"></script>
<script src="/assets/js/bootstrap-typeahead.js"></script>
<script src="/assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="/assets/js/holder/holder.js"></script>
<script src="/assets/js/google-code-prettify/prettify.js"></script>
<script src="/assets/js/application.js"></script>
<!-- Analytics
================================================== -->
<script>
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4f0dc9fef5a1f55508000013');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>

View File

@ -0,0 +1,43 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>
{% if page.title == "Bootstrap" %}
{{ page.title }}
{% else if %}
{{ page.title }} &middot; Bootstrap
{% endif %}
</title>
<!-- Bootstrap core CSS -->
<link href="/assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="/assets/css/docs.css" rel="stylesheet">
<link href="/assets/css/pygments-manni.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="/assets/js/html5shiv.js"></script>
<script src="/assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="/assets/ico/favicon.png">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-146052-10']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

View File

@ -0,0 +1,8 @@
{% raw %}
<header class="bs-docs-jumbotron subhead">
<div class="container">
<h1>{{ page.title }}</h1>
<p class="lead">{{ page.description }}</p>
</div>
</header>
{% endraw %}

View File

@ -0,0 +1,37 @@
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="/">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li {% if page.title == "Bootstrap" %}class="active"{% endif %}>
<a href="/">Home</a>
</li>
<li {% if page.title == "Getting started" %}class="active"{% endif %}>
<a href="/getting-started">Get started</a>
</li>
<li {% if page.title == "CSS" %}class="active"{% endif %}>
<a href="/css">CSS</a>
</li>
<li {% if page.title == "Components" %}class="active"{% endif %}>
<a href="/components">Components</a>
</li>
<li {% if page.title == "JavaScript plugins" %}class="active"{% endif %}>
<a href="/javascript">JavaScript</a>
</li>
<li {% if page.title == "Customize and download" %}class="active"{% endif %}>
<a href="/customize">Customize</a>
</li>
<li {% if page.title == "Gallery" %}class="active"{% endif %}>
<a href="/gallery">Gallery</a>
</li>
</ul>
</div>
</div>
</div>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta, title, CSS, favicons, etc. -->
{% include header.html %}
<!-- Place anything custom after this. -->
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Main navbar for all docs pages. -->
{% include navbar.html %}
<!-- Page content of course! -->
{{ content }}
<!-- Main docs footer (social buttons, copyright, etc). -->
{% include colophon.html %}
<!-- JS and analytics only. -->
{% include footer.html %}
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta, title, CSS, favicons, etc. -->
{% include header.html %}
<!-- Place anything custom after this. -->
</head>
<body>
<!-- Page content of course! -->
{{ content }}
<!-- JS and analytics only. -->
{% include footer.html %}
</body>
</html>

View File

@ -3254,7 +3254,7 @@ button.close {
.navbar-inverse .nav > .active > a:hover,
.navbar-inverse .nav > .active > a:focus {
color: #ffffff;
background-color: #222222;
background-color: #080808;
}
.navbar-inverse .btn-navbar {
@ -3270,7 +3270,7 @@ button.close {
.navbar-inverse .nav li.dropdown.active > .dropdown-toggle,
.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle {
color: #ffffff;
background-color: #222222;
background-color: #080808;
}
.navbar-inverse .nav li.dropdown > a:hover .caret {

View File

@ -198,6 +198,8 @@ section > ul li {
padding: 39px 14px 14px;
margin-bottom: -1px;
border: 1px solid #ddd;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/* Echo out a label for the example */
.bs-docs-example:after {
@ -211,10 +213,13 @@ section > ul li {
color: #9da0a4;
background-color: #f5f5f5;
border: 1px solid #ddd;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
}
/* Tweak display of the examples */
.bs-docs-example + .prettyprint {
.bs-docs-example + .prettyprint,
.bs-docs-example + .highlight {
margin-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
@ -485,6 +490,33 @@ input.focused {
overflow: auto;
}
.highlight {
padding: 9px 14px;
margin-bottom: 14px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
border-radius: 4px;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
.highlight pre {
padding: 0;
margin-bottom: 0;
background-color: transparent;
border: 0;
}
.highlight pre code {
font-size: inherit;
color: #333; /* Effectively the base text color */
}
.highlight pre .lineno {
display: inline-block;
width: 18px;
padding-right: 5px;
margin-right: 10px;
text-align: right;
color: #bebec5;
}
/* Docs gallery

View File

@ -0,0 +1,62 @@
.hll { background-color: #ffffcc }
{ background: #f0f3f3; }
.c { color: #999; } /* Comment */
.err { color: #AA0000; background-color: #FFAAAA } /* Error */
.k { color: #006699; } /* Keyword */
.o { color: #555555 } /* Operator */
.cm { color: #0099FF; font-style: italic } /* Comment.Multiline */
.cp { color: #009999 } /* Comment.Preproc */
.c1 { color: #999; } /* Comment.Single */
.cs { color: #999; } /* Comment.Special */
.gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #003300; } /* Generic.Heading */
.gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */
.go { color: #AAAAAA } /* Generic.Output */
.gp { color: #000099; } /* Generic.Prompt */
.gs { } /* Generic.Strong */
.gu { color: #003300; } /* Generic.Subheading */
.gt { color: #99CC66 } /* Generic.Traceback */
.kc { color: #006699; } /* Keyword.Constant */
.kd { color: #006699; } /* Keyword.Declaration */
.kn { color: #006699; } /* Keyword.Namespace */
.kp { color: #006699 } /* Keyword.Pseudo */
.kr { color: #006699; } /* Keyword.Reserved */
.kt { color: #007788; } /* Keyword.Type */
.m { color: #FF6600 } /* Literal.Number */
.s { color: #d44950 } /* Literal.String */
.na { color: #4f9fcf } /* Name.Attribute */
.nb { color: #336666 } /* Name.Builtin */
.nc { color: #00AA88; } /* Name.Class */
.no { color: #336600 } /* Name.Constant */
.nd { color: #9999FF } /* Name.Decorator */
.ni { color: #999999; } /* Name.Entity */
.ne { color: #CC0000; } /* Name.Exception */
.nf { color: #CC00FF } /* Name.Function */
.nl { color: #9999FF } /* Name.Label */
.nn { color: #00CCFF; } /* Name.Namespace */
.nt { color: #2f6f9f; } /* Name.Tag */
.nv { color: #003333 } /* Name.Variable */
.ow { color: #000000; } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mf { color: #FF6600 } /* Literal.Number.Float */
.mh { color: #FF6600 } /* Literal.Number.Hex */
.mi { color: #FF6600 } /* Literal.Number.Integer */
.mo { color: #FF6600 } /* Literal.Number.Oct */
.sb { color: #CC3300 } /* Literal.String.Backtick */
.sc { color: #CC3300 } /* Literal.String.Char */
.sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */
.s2 { color: #CC3300 } /* Literal.String.Double */
.se { color: #CC3300; } /* Literal.String.Escape */
.sh { color: #CC3300 } /* Literal.String.Heredoc */
.si { color: #AA0000 } /* Literal.String.Interpol */
.sx { color: #CC3300 } /* Literal.String.Other */
.sr { color: #33AAAA } /* Literal.String.Regex */
.s1 { color: #CC3300 } /* Literal.String.Single */
.ss { color: #FFCC33 } /* Literal.String.Symbol */
.bp { color: #336666 } /* Name.Builtin.Pseudo */
.vc { color: #003333 } /* Name.Variable.Class */
.vg { color: #003333 } /* Name.Variable.Global */
.vi { color: #003333 } /* Name.Variable.Instance */
.il { color: #FF6600 } /* Literal.Number.Integer.Long */

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 205 KiB

View File

@ -1,30 +0,0 @@
.com { color: #93a1a1; }
.lit { color: #195f91; }
.pun, .opn, .clo { color: #93a1a1; }
.fun { color: #dc322f; }
.str, .atv { color: #D14; }
.kwd, .prettyprint .tag { color: #1e347b; }
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }
.prettyprint {
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.prettyprint.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin: 0 0 0 40px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 20px;
text-shadow: 0 1px 0 #fff;
}

View File

@ -1,28 +0,0 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

44
docs/build/index.js vendored
View File

@ -1,44 +0,0 @@
#!/usr/bin/env node
var hogan = require('hogan.js')
, fs = require('fs')
, prod = process.argv[2] == 'production'
, title = 'Bootstrap'
var layout, pages
// compile layout template
layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8')
layout = hogan.compile(layout, { sectionTags: [{o:'_i', c:'i'}] })
// retrieve pages
pages = fs.readdirSync(__dirname + '/../templates/pages')
// iterate over pages
pages.forEach(function (name) {
if (!name.match(/\.mustache$/)) return
var page = fs.readFileSync(__dirname + '/../templates/pages/' + name, 'utf-8')
, context = {}
context[name.replace(/\.mustache$/, '')] = 'active'
context._i = true
context.production = prod
context.title = name
.replace(/\.mustache/, '')
.replace(/\-.*/, '')
.replace(/(.)/, function ($1) { return $1.toUpperCase() })
if (context.title == 'Index') {
context.title = title
} else {
context.title += ' · ' + title
}
page = hogan.compile(page, { sectionTags: [{o:'_i', c:'i'}] })
page = layout.render(context, {
body: page
})
fs.writeFileSync(__dirname + '/../' + name.replace(/mustache$/, 'html'), page, 'utf-8')
})

93
docs/build/node_modules/.bin/hulk generated vendored
View File

@ -1,93 +0,0 @@
#!/usr/bin/env node
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var hogan = require('../lib/hogan.js'),
path = require('path'),
fs = require('fs');
var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'],
specialsRegExp = new RegExp('(\\' + specials.join('|\\') + ')', 'g'),
templates;
// Escape special regexp characters
function esc(text) {
return text.replace(specialsRegExp, '\\$1');
}
// Check for dirs and correct ext (<3 for windows)
function extractFiles(args) {
var usage = 'USAGE: hulk ./templates/*.mustaches\n' +
'NOTE: hulk supports the "*" wildcard and allows you to target specific extensions too',
files = [];
if (!args.length) {
console.log(usage);
process.exit(-1);
}
args.forEach(function (arg) {
if (/\*/.test(arg)) {
arg = arg.split('*');
return files = files.concat(
fs.readdirSync(arg[0] || '.')
.map(function (f) {
return new RegExp(esc(arg[1]) + '$').test(f) && path.join(arg[0], f);
})
.filter(function (f) {
return f;
})
);
}
files.push(arg);
})
return files;
}
// Remove utf-8 byte order mark, http://en.wikipedia.org/wiki/Byte_order_mark
function removeByteOrderMark(text) {
if (text.charCodeAt(0) === 0xfeff) {
return text.substring(1);
}
return text;
}
// Write a template foreach file that matches template extension
templates = extractFiles(process.argv.slice(2))
.map(function (file) {
var openedFile = fs.readFileSync(file, 'utf-8'), name;
if (!openedFile) return;
name = file.replace(/\..*$/, '');
openedFile = removeByteOrderMark(openedFile.trim());
return 'templates.' + name + ' = new Hogan.Template(' + hogan.compile(openedFile, { asString: 1 }) + ');';
})
.filter(function (t) {
return t;
});
// Output templates
if (!templates.length) return;
console.log('var templates = {};');
console.log(templates.join('\n'));

View File

@ -1 +0,0 @@
node_modules

View File

@ -1,3 +0,0 @@
[submodule "test/spec"]
path = test/spec
url = https://github.com/mustache/spec.git

View File

@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@ -1,62 +0,0 @@
REPO = git@github.com:twitter/hogan.js.git
BUILD := build
VERSION = ${shell node -e 'var s = JSON.parse(require("fs").readFileSync("package.json").toString()).version; console.log(s.substring(0, s.indexOf("-")));'}
#
# Run command line tests
#
test:
@ node test/index.js
#
# Run Mustache spec tests
#
spec:
@ node test/spec.js
#
# Run benchmark
#
benchmark:
@ node benchmark/console/index.js
clean:
@ rm -rf dist/*
#
# Make a new version of Hogan from the current dev version.
#
release: clean
@ echo "Creating a new version of Hogan."
@ mkdir -p dist/nodejs
@ cp -R lib dist/nodejs/lib
@ node tools/release.js
@ mkdir -p web/builds/$(VERSION)
@ cp dist/*.* web/builds/$(VERSION)/.
#
# Make the gh-pages website
#
# This target builds the hogan.js github website using hogan.js.
#
# cd into build/gh-pages to check in the new site.
#
GH_PAGES = $(BUILD)/gh-pages
web: | pages
@cp -R web/* $(GH_PAGES)
@@ node tools/web_templates.js
@echo
@echo "Website built in $(GH_PAGES)."
#
# Checkout the gh-pages branch.
#
pages: | $(BUILD)
@if [ ! -d "$(GH_PAGES)" ]; then \
git clone -b gh-pages $(REPO) $(GH_PAGES); \
rm -rf $(GH_PAGES)/*; \
fi;
@mkdir -p $(GH_PAGES)/images
$(BUILD):
mkdir -p $(BUILD)
.PHONY: test spec benchmark web release

View File

@ -1,93 +0,0 @@
## Hogan.js - A mustache compiler.
[Hogan.js](http://twitter.github.com/hogan.js/) is a compiler for the
[Mustache](http://mustache.github.com/) templating language. For information
on Mustache, see the [manpage](http://mustache.github.com/mustache.5.html) and
the [spec](https://github.com/mustache/spec).
## Basics
Hogan compiles templates to HoganTemplate objects, which have a render method.
```js
var data = {
screenName: "dhg",
};
var template = Hogan.compile("Follow @{{screenName}}.");
var output = template.render(data);
// prints "Follow @dhg."
console.log(output);
```
## Features
Hogan is fast--try it on your workload.
Hogan has separate scanning, parsing and code generation phases. This way it's
possible to add new features without touching the scanner at all, and many
different code generation techniques can be tried without changing the parser.
Hogan exposes scan and parse methods. These can be useful for
pre-processing templates on the server.
```js
var text = "{{^check}}{{i18n}}No{{/i18n}}{{/check}}";
text += "{{#check}}{{i18n}}Yes{{/i18n}}{{/check}}";
var tree = Hogan.parse(Hogan.scan(text));
// outputs "# check"
console.log(tree[0].tag + " " + tree[0].name);
// outputs "Yes"
console.log(tree[1].nodes[0].nodes[0]);
```
It's also possible to use HoganTemplate objects without the Hogan compiler
present. That means you can pre-compile your templates on the server, and
avoid shipping the compiler. However, the optional lambda features from the
Mustache spec do require the compiler to be present.
## Why Hogan.js?
Why another templating library?
Hogan.js was written to meet three templating library requirements: good
performance, standalone template objects, and a parser API.
## Issues
Have a bug? Please create an issue here on GitHub!
https://github.com/twitter/hogan.js/issues
## Versioning
For transparency and insight into our release cycle, releases will be numbered with the follow format:
`<major>.<minor>.<patch>`
And constructed with the following guidelines:
* Breaking backwards compatibility bumps the major
* New additions without breaking backwards compatibility bumps the minor
* Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit http://semver.org/.
## Authors
**Robert Sayre**
+ http://github.com/sayrer
**Jacob Thornton**
+ http://github.com/fat
## License
Copyright 2011 Twitter, Inc.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

View File

@ -1,93 +0,0 @@
#!/usr/bin/env node
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var hogan = require('../lib/hogan.js'),
path = require('path'),
fs = require('fs');
var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'],
specialsRegExp = new RegExp('(\\' + specials.join('|\\') + ')', 'g'),
templates;
// Escape special regexp characters
function esc(text) {
return text.replace(specialsRegExp, '\\$1');
}
// Check for dirs and correct ext (<3 for windows)
function extractFiles(args) {
var usage = 'USAGE: hulk ./templates/*.mustaches\n' +
'NOTE: hulk supports the "*" wildcard and allows you to target specific extensions too',
files = [];
if (!args.length) {
console.log(usage);
process.exit(-1);
}
args.forEach(function (arg) {
if (/\*/.test(arg)) {
arg = arg.split('*');
return files = files.concat(
fs.readdirSync(arg[0] || '.')
.map(function (f) {
return new RegExp(esc(arg[1]) + '$').test(f) && path.join(arg[0], f);
})
.filter(function (f) {
return f;
})
);
}
files.push(arg);
})
return files;
}
// Remove utf-8 byte order mark, http://en.wikipedia.org/wiki/Byte_order_mark
function removeByteOrderMark(text) {
if (text.charCodeAt(0) === 0xfeff) {
return text.substring(1);
}
return text;
}
// Write a template foreach file that matches template extension
templates = extractFiles(process.argv.slice(2))
.map(function (file) {
var openedFile = fs.readFileSync(file, 'utf-8'), name;
if (!openedFile) return;
name = file.replace(/\..*$/, '');
openedFile = removeByteOrderMark(openedFile.trim());
return 'templates.' + name + ' = new Hogan.Template(' + hogan.compile(openedFile, { asString: 1 }) + ');';
})
.filter(function (t) {
return t;
});
// Output templates
if (!templates.length) return;
console.log('var templates = {};');
console.log(templates.join('\n'));

View File

@ -1,348 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function (Hogan) {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
Hogan.scan = function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
if (ctag == '}}') {
i++;
} else {
cleanTripleStache(tokens[tokens.length - 1]);
}
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function cleanTripleStache(token) {
if (token.n.substr(token.n.length - 1) === '}') {
token.n = token.n.substring(0, token.n.length - 1);
}
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function writeCode(tree) {
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
}
Hogan.generate = function (code, text, options) {
if (options.asString) {
return 'function(c,p,i){' + code + ';}';
}
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
Hogan.parse = function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
Hogan.cache = {};
Hogan.compile = function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var key = text + '||' + !!options.asString;
var t = this.cache[key];
if (t) {
return t;
}
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
return this.cache[key] = t;
};
})(typeof exports !== 'undefined' ? exports : Hogan);

View File

@ -1,20 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file is for use with Node.js. See dist/ for browser files.
var Hogan = require('./compiler');
Hogan.Template = require('./template').Template;
module.exports = Hogan;

View File

@ -1,233 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);

View File

@ -1,20 +0,0 @@
{
"name": "hogan.js"
, "description": "A mustache compiler."
, "version": "1.0.5-dev"
, "keywords": ["mustache", "template"]
, "main": "./lib/hogan.js"
, "homepage": "http://twitter.github.com/hogan.js/"
, "author": "Twitter Inc."
, "repository": {
"type": "git"
, "url": "https://github.com/twitter/hogan.js.git"
}
, "licenses": [
{ "type": "Apache-2.0"
, "url": "http://www.apache.org/licenses/LICENSE-2.0"
}
]
, "devDependencies": { "uglify-js": "*" }
, "bin" : { "hulk" : "./bin/hulk" }
}

View File

@ -1,8 +0,0 @@
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

View File

@ -1,13 +0,0 @@
<html>
<head>
<title>test</title>
<script src="https://raw.github.com/douglascrockford/JSON-js/master/json2.js"></script>
</head>
<body>
<code id="console"></code>
<script>var Hogan = {};</script>
<script src="../lib/template.js"></script>
<script src="../lib/compiler.js"></script>
<script src="./index.js"></script>
</body>
</html>

View File

@ -1,848 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = Hogan || require('../lib/hogan')
, doc = this["document"]
function testScanTextNoTags() {
var text = "<h2>hi</h2>";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0]+'', text, "text is equal to first token");
}
function testScanOneTag() {
var text = "{{hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
}
function testScanMultipleTags() {
var text = "asdf{{hmm}}asdf2{{hmm2}}asdf3";
var tokens = Hogan.scan(text);
is(tokens.length, 5, "3 text tokens, 2 tag tokens.");
is(tokens[0]+'', "asdf", "first token is text");
is(tokens[1].n, "hmm", "second token is tag");
is(tokens[1].tag, "_v", "second token is a variable");
is(tokens[2]+'', "asdf2", "third token is text");
is(tokens[3].n, "hmm2", "fourth token is tag");
is(tokens[3].tag, "_v", "fourth token is a variable");
is(tokens[4]+'', "asdf3", "Fifth token is text");
}
function testScanSectionOpen() {
var text = "{{#hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "#", "First token is a section.");
}
function testScanSectionClose() {
var text = "{{/hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "/", "First token is a section.");
}
function testScanSection() {
var text = "{{#hmm}}{{/hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 2, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "#", "First token is a section.");
is(tokens[1].n, "hmm", "Second token content is variable name.");
is(tokens[1].tag, "/", "Second token is a section.");
}
function testScanSectionInContent() {
var text = "abc{{#hmm}}def{{/hmm}}ghi";
var tokens = Hogan.scan(text);
is(tokens.length, 5, "3 text tokens, 2 tag tokens.");
is(tokens[0]+'', "abc", "first token is text");
is(tokens[1].n, "hmm", "second token is tag");
is(tokens[1].tag, "#", "second token is a variable");
is(tokens[2]+'', "def", "third token is text");
is(tokens[3].n, "hmm", "fourth token is tag");
is(tokens[3].tag, "/", "fourth token is a variable");
is(tokens[4]+'', "ghi", "Fifth token is text");
}
function testScanNegativeSection() {
var text = "{{^hmm}}{{/hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 2, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "^", "First token is a negative section.");
is(tokens[1].n, "hmm", "First token content is variable name.");
is(tokens[1].tag, "/", "Second token is a section.");
}
function testScanPartial() {
var text = "{{>hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, ">", "First token is a partial.");
}
function testScanBackwardPartial() {
var text = "{{<hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "<", "First token is a backward partial.");
}
function testScanAmpersandNoEscapeTag() {
var text = "{{&hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "&", "First token is an ampersand no-escape.");
}
function testScanTripleStache() {
var text = "{{{hmm}}}";
var tokens = Hogan.scan(text);
is(tokens.length, 1, "One token");
is(tokens[0].n, "hmm", "First token content is variable name.");
is(tokens[0].tag, "{", "First token is a triple-stache.");
}
function testScanSectionWithTripleStacheInside() {
var text = "a{{#yo}}b{{{hmm}}}c{{/yo}}d";
var tokens = Hogan.scan(text);
is(tokens.length, 7, "One token");
is(tokens[0]+'', "a", "First token content is correct text.");
is(tokens[1].n, "yo", "Second token content is correct text.");
is(tokens[1].tag, "#", "Second token is a section.");
is(tokens[2]+'', "b", "Third token content is correct text.");
is(tokens[3].n, "hmm", "Fourth token content is correct text.");
is(tokens[3].tag, "{", "Fourth token is a triple stache.");
is(tokens[4]+'', "c", "Fifth token content is correct text.");
is(tokens[5].n, "yo", "Sixth token content is correct text.");
is(tokens[5].tag, "/", "Sixth token is a close.");
is(tokens[6]+'', "d", "Seventh token content is correct text.");
}
function testScanSetDelimiter() {
var text = "a{{=<% %>=}}b";
var tokens = Hogan.scan(text);
is(tokens.length, 2, "change delimiter doesn't appear as token.");
is(tokens[0]+'', "a", "text before change delimiter is processed.");
is(tokens[1]+'', "b", "text after change delimiter is processed.");
}
function testScanResetDelimiter() {
var text = "a{{=<% %>=}}b<%hmm%>c<%={{ }}=%>d{{hmm}}";
var tokens = Hogan.scan(text);
is(tokens.length, 6, "8 tokens, delimiter changes don't count.");
is(tokens[0]+'', "a", "first token is correct.");
is(tokens[1]+'', "b", "third token is correct.");
is(tokens[2].tag, "_v", "third token is correct tag.");
is(tokens[2].n, "hmm", "third token is correct name.");
is(tokens[3]+'', "c", "fifth token is correct.");
is(tokens[4]+'', "d", "seventh token is correct.");
is(tokens[5].tag, "_v", "eighth token is correct tag.");
is(tokens[5].n, "hmm", "eighth token is correct name.");
}
function testSingleCharDelimiter() {
var text = '({{foo}} {{=[ ]=}}[text])';
var tokens = Hogan.scan(text);
var t = Hogan.compile(text);
s = t.render({foo: "bar", text: 'It worked!'});
is(s, '(bar It worked!)', "Hogan substitution worked after custom delimiters.");
}
function testSetDelimiterWithWhitespace() {
var text = "{{= | | =}}|foo|";
var t = Hogan.compile(text);
s = t.render({foo: "bar"});
is(s, 'bar', "custom delimiters with whitespace works.")
}
function testParseBasic() {
var text = "test";
var tree = Hogan.parse(Hogan.scan(text));
is(tree.length, 1, "one parse node");
is(tree[0]+'', "test", "text is correct");
}
function testParseVariables() {
var text = "test{{foo}}test!{{bar}}test!!{{baz}}test!!!";
var tree = Hogan.parse(Hogan.scan(text));
is(tree.length, 7, "one parse node");
is(tree[0]+'', "test", "first text is correct");
is(tree[2]+'', "test!", "second text is correct")
is(tree[4]+'', "test!!", "third text is correct")
is(tree[6]+'', "test!!!", "last text is correct")
is(tree[1].n, "foo", "first var is correct");
is(tree[3].n, "bar", "second var is correct");
is(tree[5].n, "baz", "third var is correct");
}
function testParseSection() {
var text = "a{{#foo}}b{{/foo}}c";
var tree = Hogan.parse(Hogan.scan(text));
is(tree.length, 3, "three nodes at base");
is(tree[0]+'', "a", "correct text in first node");
is(tree[1].hasOwnProperty('nodes'), true, "second node is a section");
is(tree[1].tag, '#', "second node is a section");
is(tree[1].n, "foo", "correct name for section");
is(tree[1].nodes[0]+'', "b", "correct text in section");
is(tree[2]+'', "c", "correct text in last node");
}
function testParseIndexes() {
var text = "abc{{#foo}}asdf{{bar}}asdf{{/foo}}def";
var tree = Hogan.parse(Hogan.scan(text));
is(text.substring(tree[1].i, tree[1].end), "asdf{{bar}}asdf", "section text indexes are correct");
}
function testParseNegativeSection() {
var text = "a{{^foo}}b{{/foo}}c";
var tree = Hogan.parse(Hogan.scan(text));
is(tree.length, 3, "three nodes at base");
is(tree[0]+'', "a", "correct text in first node");
is(tree[1].hasOwnProperty('nodes'), true, "second node is a section");
is(tree[1].tag, '^', "second node is a negative section");
is(tree[1].n, "foo", "correct name for section");
is(tree[1].nodes[0]+'', "b", "correct text in section");
is(tree[2]+'', "c", "correct text in last node");
}
function testParseNestedSections() {
var text = "{{#bar}}{{#foo}}c{{/foo}}{{/bar}}"
var tree = Hogan.parse(Hogan.scan(text));
is(tree.length, 1, "one node at base");
is(tree[0].tag, "#", "open section is first node");
is(tree[0].n, "bar", "first section name is 'bar'");
is(tree[0].nodes.length, 1, "first section contains one node.");
is(tree[0].nodes[0].n, "foo", "correct name for nested section");
is(tree[0].nodes[0].nodes[0]+'', "c", "correct text in nested section");
}
function testMissingClosingTag() {
var text = "a{{#foo}}bc";
var msg = '';
try {
var tree = Hogan.parse(Hogan.scan(text));
} catch (e) {
msg = e.message;
}
is(msg, "missing closing tag: foo", "Error is generated");
}
function testBadNesting() {
var text = "a{{#foo}}{{#bar}}b{{/foo}}{{/bar}}c";
var msg = '';
try {
var tree = Hogan.parse(Hogan.scan(text));
} catch (e) {
msg = e.message;
}
is(msg, "Nesting error: bar vs. foo", "Error is generated");
}
function testBasicOutput() {
var text = "test";
var t = Hogan.compile(text);
is(t.render(), text, "template renders one text node");
}
function testBasicOutputAsString() {
var text = "test";
var textFunc = Hogan.compile(text, true);
is(textFunc, "function(context, partials){this.buffer.push('test');};", "template renders correct text function.");
}
function testOneVariable() {
var text = "test {{foo}} test";
var t = Hogan.compile(text);
var s = t.render({foo:'bar'});
is(s, "test bar test", "basic variable substitution works.");
}
function testOneVariableAsString() {
var text = "test {{foo}} test";
var funcText = Hogan.compile(text, true);
is(funcText, "function(context, partials){this.buffer.push('test ');\nthis.buffer.push(this.find('foo', context));\nthis.buffer.push(' test');};",
"Function text is correct with variable substitution.");
}
function testRenderWithWhitespace() {
var text = "{{ string }}";
var t = Hogan.compile(text);
is(t.render({string: "---" }), "---", "tags with whitespace render correctly.");
}
function testRenderWithWhitespaceAroundTripleStache() {
var text = " {{{string}}}\n";
var t = Hogan.compile(text);
is(t.render({string: "---" }), " ---\n", "triple stache surrounded by whitespace render correctly.");
}
function testRenderWithWhitespaceAroundAmpersand() {
var text = " {{& string }}\n";
var t = Hogan.compile(text);
is(t.render({string: "---" }), " ---\n", "ampersand surrounded by whitespace render correctly.");
}
function testMultipleVariables() {
var text = "test {{foo}} test {{bar}} test {{baz}} test {{foo}} test";
var t = Hogan.compile(text);
var s = t.render({foo:'42', bar: '43', baz: '44'});
is(s, "test 42 test 43 test 44 test 42 test", "all variables render correctly.");
}
function testNumberValues() {
var text = "integer: {{foo}} float: {{bar}} negative: {{baz}}";
var t = Hogan.compile(text);
var s = t.render({foo: 42, bar: 42.42, baz: -42});
is(s, "integer: 42 float: 42.42 negative: -42", "numbers render correctly");
}
function testObjectRender() {
var text = "object: {{foo}}";
var t = Hogan.compile(text);
var s = t.render({foo: {}});
is(s, "object: [object Object]", "objects render default toString.");
}
function testObjectToStringRender() {
var text = "object: {{foo}}";
var t = Hogan.compile(text);
var s = t.render({foo: {toString: function(){ return "yo!"}}});
is(s, "object: yo!", "objects render supplied toString.");
}
function testArrayRender() {
var text = "array: {{foo}}";
var t = Hogan.compile(text);
var s = t.render({foo: ["a","b","c"]});
is(s, "array: a,b,c", "arrays render default toString.");
}
function testEscaping() {
var text = "{{foo}}";
var t = Hogan.compile(text);
var s = t.render();
var s = t.render({foo: "< > <div> \' \" &"});
is(s, "&lt; &gt; &lt;div&gt; &#39; &quot; &amp;", "input correctly escaped.");
var ec ={ "'": "&#39;", '"': "&quot;", "<": "&lt;", ">": "&gt;", "&": "&amp;"}
for (var char in ec) {
var s = t.render({foo: char + " just me"});
is(s, ec[char] + " just me", "input correctly escaped.");
}
}
function testMustacheInjection() {
var text = "{{foo}}";
var t = Hogan.compile(text);
s = t.render({foo:"{{{<42}}}"})
is(s, "{{{&lt;42}}}", "Can't inject mustache");
}
function testTripleStache() {
var text = "{{{foo}}}";
var t = Hogan.compile(text);
var s = t.render({foo: "< > <div> \' \" &"});
is(s, "< > <div> \' \" &", "input correctly not-escaped.");
}
function testAmpNoEscaping() {
var text = "{{&foo}}";
var t = Hogan.compile(text);
var s = t.render({foo: "< > <div> \' \" &"});
is(s, "< > <div> \' \" &", "input correctly not-escaped.");
}
function testPartial() {
var partialText = "this is text from the partial--the magic number {{foo}} is from a variable";
var p = Hogan.compile(partialText);
var text = "This template contains a partial ({{>testPartial}})."
var t = Hogan.compile(text);
var s = t.render({foo: 42}, {testPartial: p});
is(s, "This template contains a partial (this is text from the partial--the magic number 42 is from a variable).", "partials work");
}
function testNestedPartials() {
var partialText = "this is text from the partial--the magic number {{foo}} is from a variable";
var p = Hogan.compile(partialText);
var partialText2 = "This template contains a partial ({{>testPartial}})."
var p2 = Hogan.compile(partialText2);
var text = "This template contains a partial that contains a partial [{{>testPartial2}}]."
var t = Hogan.compile(text);
var s = t.render({foo: 42}, {testPartial: p, testPartial2: p2});
is(s, "This template contains a partial that contains a partial [This template contains a partial (this is text from the partial--the magic number 42 is from a variable).].", "nested partials work");
}
function testNegativeSection() {
var text = "This template {{^foo}}BOO {{/foo}}contains an inverted section."
var t = Hogan.compile(text);
var s = t.render();
is(s, "This template BOO contains an inverted section.", "inverted sections with no context work");
s = t.render({foo:[]});
is(s, "This template BOO contains an inverted section.", "inverted sections with empty list context work");
s = t.render({ foo:false });
is(s, "This template BOO contains an inverted section.", "inverted sections with false context work");
s = t.render({foo:''});
is(s, "This template contains an inverted section.", "inverted sections with empty string context work");
s = t.render({foo:true});
is(s, "This template contains an inverted section.", "inverted sections with true context work");
s = t.render({foo: function() { return false; }});
is(s, "This template BOO contains an inverted section.", "inverted sections with false returning method in context work");
}
function testSectionElision() {
var text = "This template {{#foo}}BOO {{/foo}}contains a section."
var t = Hogan.compile(text);
var s = t.render();
is(s, "This template contains a section.", "sections with no context work");
s = t.render({foo:[]});
is(s, "This template contains a section.", "sections with empty list context work");
s = t.render({foo:false});
is(s, "This template contains a section.", "sections with false context work");
}
function testSectionObjectContext() {
var text = "This template {{#foo}}{{bar}} {{/foo}}contains a section."
var t = Hogan.compile(text);
var s = t.render({foo:{bar:42}});
is(s, "This template 42 contains a section.", "sections with object context work");
}
function testSectionArrayContext() {
var text = "This template {{#foo}}{{bar}} {{/foo}}contains a section."
var t = Hogan.compile(text);
var s = t.render({foo:[{bar:42}, {bar:43}, {bar:44}]});
is(s, "This template 42 43 44 contains a section.", "sections with object ctx and array values work");
}
function testFalsyVariableNoRender() {
var text = "I ({{cannot}}) be seen!";
var t = Hogan.compile(text);
var s = t.render();
is(s, "I () be seen!", "missing value doesn't render.");
}
function testSectionExtensions() {
var text = "Test {{_//|__foo}}bar{{/foo}}";
var options = {sectionTags:[{o:'_//|__foo', c:'foo'}]};
var tree = Hogan.parse(Hogan.scan(text), options);
is(tree[1].tag, "#", "_//|__foo node transformed to section");
is(tree[1].n, "_//|__foo", "_//|__foo node transformed to section");
var t = Hogan.compile(text, options );
var s = t.render({'_//|__foo':true});
is(s, "Test bar", "Custom sections work");
}
function testMisnestedSectionExtensions() {
var text = "Test {{__foo}}bar{{/bar}}";
var options = {sectionTags:[{o:'__foo', c:'foo'}, {o:'__bar', c:'bar'}]};
var msg = '';
try {
var tree = Hogan.parse(Hogan.scan(text), options);
} catch (e) {
msg = e.message;
}
is(msg, "Nesting error: __foo vs. bar", "Error is generated");
}
function testNestedSection() {
var text = "{{#foo}}{{#bar}}{{baz}}{{/bar}}{{/foo}}";
var t = Hogan.compile(text);
var s = t.render({foo: 42, bar: 42, baz:42});
is(s, "42", "can reach up context stack");
}
function testDottedNames() {
var text = '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"';
var t = Hogan.compile(text);
var s = t.render({person:{name:'Joe'}});
is(s, '"Joe" == "Joe"', "dotted names work");
}
function testImplicitIterator() {
var text = '{{#stuff}} {{.}} {{/stuff}}';
var t = Hogan.compile(text);
var s = t.render({stuff:[42,43,44]});
is(s, " 42 43 44 ", "implicit iterators work");
}
function testPartialsAndDelimiters() {
var text = '{{>include}}*\n{{= | | =}}\n*|>include|';
var partialText = ' .{{value}}. ';
var partial = Hogan.compile(partialText);
var t = Hogan.compile(text);
var s = t.render({value:"yes"}, {'include':partial});
is(s, " .yes. *\n* .yes. ", "partials work around delimiters");
}
function testStringPartials() {
var text = "foo{{>mypartial}}baz";
var partialText = " bar ";
var t = Hogan.compile(text);
var s = t.render({}, {'mypartial': partialText});
is(s, "foo bar baz", "string partial works.");
}
function testMissingPartials() {
var text = "foo{{>mypartial}} bar";
var t = Hogan.compile(text);
var s = t.render({});
is(s, "foo bar", "missing partial works.");
}
function testIndentedStandaloneComment() {
var text = 'Begin.\n {{! Indented Comment Block! }}\nEnd.';
var t = Hogan.compile(text);
var s = t.render();
is(s, 'Begin.\nEnd.', "Standalone comment blocks are removed.");
}
function testNewLineBetweenDelimiterChanges() {
var data = { section: true, data: 'I got interpolated.' };
var text = '\n{{#section}}\n {{data}}\n |data|\n{{/section}}x\n\n{{= | | =}}\n|#section|\n {{data}}\n |data|\n|/section|';
var t = Hogan.compile(text);
var s = t.render(data);
is(s, '\n I got interpolated.\n |data|\nx\n\n {{data}}\n I got interpolated.\n', 'render correct')
}
function testMustacheJSApostrophe() {
var text = '{{apos}}{{control}}';
var t = Hogan.compile(text);
var s = t.render({'apos':"'", 'control':"X"});
is(s, '&#39;X', 'Apostrophe is escaped.');
}
function testMustacheJSArrayOfImplicitPartials() {
var text = 'Here is some stuff!\n{{#numbers}}\n{{>partial}}\n{{/numbers}}\n';
var partialText = '{{.}}\n';
var t = Hogan.compile(text);
var s = t.render({numbers:[1,2,3,4]}, {partial: partialText});
is(s, 'Here is some stuff!\n1\n2\n3\n4\n', 'Partials with implicit iterators work.');
}
function testMustacheJSArrayOfPartials() {
var text = 'Here is some stuff!\n{{#numbers}}\n{{>partial}}\n{{/numbers}}\n';
var partialText = '{{i}}\n';
var t = Hogan.compile(text);
var s = t.render({numbers:[{i:1},{i:2},{i:3},{i:4}]}, {partial: partialText});
is(s, 'Here is some stuff!\n1\n2\n3\n4\n', 'Partials with arrays work.');
}
function testMustacheJSArrayOfStrings() {
var text = '{{#strings}}{{.}} {{/strings}}';
var t = Hogan.compile(text);
var s = t.render({strings:['foo', 'bar', 'baz']});
is(s, 'foo bar baz ', 'array of strings works with implicit iterators.');
}
function testMustacheJSUndefinedString() {
var text = 'foo{{bar}}baz';
var t = Hogan.compile(text);
var s = t.render({bar:undefined});
is(s, 'foobaz', 'undefined value does not render.');
}
function testMustacheJSTripleStacheAltDelimiter() {
var text = '{{=<% %>=}}<% foo %> {{foo}} <%{bar}%> {{{bar}}}';
var t = Hogan.compile(text);
var s = t.render({foo:'yeah', bar:'hmm'});
is(s, 'yeah {{foo}} hmm {{{bar}}}', 'triple stache inside alternate delimiter works.');
}
/* shootout benchmark tests */
function testShootOutString() {
var text = "Hello World!";
var expected = "Hello World!"
var t = Hogan.compile(text)
var s = t.render({})
is(s, expected, "Shootout String compiled correctly");
}
function testShootOutReplace() {
var text = "Hello {{name}}! You have {{count}} new messages.";
var expected = "Hello Mick! You have 30 new messages.";
var t = Hogan.compile(text)
var s = t.render({ name: "Mick", count: 30 })
is(s, expected, "Shootout Replace compiled correctly");
}
function testShootOutArray() {
var text = "{{#names}}{{name}}{{/names}}";
var expected = "MoeLarryCurlyShemp";
var t = Hogan.compile(text);
var s = t.render({ names: [{name: "Moe"}, {name: "Larry"}, {name: "Curly"}, {name: "Shemp"}] })
is(s, expected, "Shootout Array compiled correctly");
}
function testShootOutObject() {
var text = "{{#person}}{{name}}{{age}}{{/person}}";
var expected = "Larry45";
var t = Hogan.compile(text)
var s = t.render({ person: { name: "Larry", age: 45 } })
is(s, expected, "Shootout Object compiled correctly");
}
function testShootOutPartial() {
var text = "{{#peeps}}{{>replace}}{{/peeps}}";
var t = Hogan.compile(text);
var partial = Hogan.compile(" Hello {{name}}! You have {{count}} new messages.");
var s = t.render({ peeps: [{name: "Moe", count: 15}, {name: "Larry", count: 5}, {name: "Curly", count: 2}] }, { replace: partial });
var expected = " Hello Moe! You have 15 new messages. Hello Larry! You have 5 new messages. Hello Curly! You have 2 new messages.";
is(s, expected, "Shootout Partial compiled correctly");
}
function testShootOutRecurse() {
var text = "{{name}}{{#kids}}{{>recursion}}{{/kids}}";
var t = Hogan.compile(text);
var partial = Hogan.compile("{{name}}{{#kids}}{{>recursion}}{{/kids}}");
var s = t.render({
name: '1',
kids: [
{
name: '1.1',
kids: [
{ name: '1.1.1', kids: [] }
]
}
]
}, { recursion: partial });
var expected = "11.11.1.1";
is(s, expected, "Shootout Recurse compiled correctly");
}
function testShootOutFilter() {
var text = "{{#filter}}foo {{bar}}{{/filter}}";
var t = Hogan.compile(text);
var s = t.render({
filter: function() {
return function(text, render) {
return render(text).toUpperCase();
}
},
bar: "bar"
});
var expected = "FOO BAR"
is(s, expected, "Shootout Filter compiled correctly");
}
function testShootOutComplex() {
var text =
"<h1>{{header}}</h1>" +
"{{#hasItems}}" +
"<ul>" +
"{{#items}}" +
"{{#current}}" +
"<li><strong>{{name}}</strong></li>" +
"{{/current}}" +
"{{^current}}" +
"<li><a href=\"{{url}}\">{{name}}</a></li>" +
"{{/current}}" +
"{{/items}}" +
"</ul>" +
"{{/hasItems}}" +
"{{^hasItems}}" +
"<p>The list is empty.</p>" +
"{{/hasItems}}";
var expected = "<h1>Colors</h1><ul><li><strong>red</strong></li><li><a href=\"#Green\">green</a></li><li><a href=\"#Blue\">blue</a></li></ul>";
var t = Hogan.compile(text)
var s = t.render({
header: function() {
return "Colors";
},
items: [
{name: "red", current: true, url: "#Red"},
{name: "green", current: false, url: "#Green"},
{name: "blue", current: false, url: "#Blue"}
],
hasItems: function() {
return this.items.length !== 0;
},
empty: function() {
return this.items.length === 0;
}
})
is(s, expected, "Shootout Complex compiled correctly");
}
function testRenderOutput() {
if (doc) return
var fs = require('fs');
var inPath = 'test/templates';
var outPath = 'test/html';
fs.readdirSync(inPath).forEach(function (file) {
var i = fs.readFileSync([inPath, file].join('/'), 'utf-8');
var t = Hogan.compile(i);
var r = t.render({});
var o = fs.readFileSync([outPath, file].join('/').replace(/mustache$/, 'html')).toString();
is(r === o, true, file + ' should correctly render html')
})
}
function testDefaultRenderImpl() {
var ht = new Hogan.Template();
is(ht.render() === '', true, 'default renderImpl returns an array.');
}
function appendText(el, text) {
var textNode = document.createTextNode(text);
el.appendChild(textNode);
el.appendChild(document.createElement('br'));
}
if (!this["output"]) {
var output = function (s) {
return doc ? appendText(doc.getElementById('console'), s) : console.log(s);
};
}
var passed = 0;
var failed = 0;
function is(got, expected, msg) {
if (got === expected) {
output("OK: " + msg);
++passed;
} else {
output("FAIL: " + msg);
output("Expected |" + expected + "|");
output(" Got |" + got + "|");
++failed;
}
}
function complete() {
output("\nTests Complete");
output("--------------");
output("Passed: " + passed);
output("Failed: " + failed);
output("\n");
}
function runTests() {
output("Tests Starting");
output("--------------");
testScanTextNoTags();
testScanOneTag();
testScanMultipleTags();
testScanSectionOpen();
testScanSectionClose();
testScanSection();
testScanSectionInContent();
testScanNegativeSection();
testScanPartial();
testScanBackwardPartial();
testScanAmpersandNoEscapeTag();
testScanTripleStache();
testScanSectionWithTripleStacheInside();
testScanSetDelimiter();
testScanResetDelimiter();
testSetDelimiterWithWhitespace();
testSingleCharDelimiter();
testParseBasic();
testParseVariables();
testParseSection();
testParseIndexes();
testParseNegativeSection();
testParseNestedSections();
testMissingClosingTag();
testBadNesting();
testBasicOutput();
//testBasicOutputAsString();
testOneVariable();
//testOneVariableAsString();
testMultipleVariables();
testNumberValues();
testObjectRender();
testObjectToStringRender();
testArrayRender();
testEscaping();
testMustacheInjection();
testTripleStache();
testAmpNoEscaping();
testPartial();
testNestedPartials();
testNegativeSection();
testSectionElision();
testSectionObjectContext();
testSectionArrayContext();
testRenderWithWhitespace();
testRenderWithWhitespaceAroundTripleStache();
testRenderWithWhitespaceAroundAmpersand();
testFalsyVariableNoRender();
testRenderOutput();
testDefaultRenderImpl();
testSectionExtensions();
testMisnestedSectionExtensions();
testNestedSection();
testShootOutString();
testShootOutReplace();
testShootOutArray();
testShootOutObject();
testShootOutPartial();
testShootOutRecurse();
testShootOutFilter();
testShootOutComplex();
testDottedNames();
testImplicitIterator();
testPartialsAndDelimiters();
testStringPartials();
testMissingPartials();
testIndentedStandaloneComment();
testNewLineBetweenDelimiterChanges();
testMustacheJSApostrophe();
testMustacheJSArrayOfImplicitPartials();
testMustacheJSArrayOfPartials();
testMustacheJSArrayOfStrings();
testMustacheJSUndefinedString();
testMustacheJSTripleStacheAltDelimiter();
complete();
}
if (doc) {
window.onload = runTests;
} else {
runTests();
}

View File

@ -1,90 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var doc = this['document'];
var fs = require('fs');
var passed = 0;
var failed = 0;
if (!this['output']) {
var output = function (string) {
return doc ? doc.write(string + '<br/>') : console.log(string);
};
}
var Hogan = require(__dirname + '/../lib/hogan');
var template = fs.readFileSync(__dirname + '/../lib/template.js').toString();
var compiler = fs.readFileSync(__dirname + '/../lib/compiler.js').toString();
var mustache_wrapper = fs.readFileSync(__dirname + '/../wrappers/mustache.js.mustache').toString();
// Create a Mustache.js emulator from the distribution template
var engines = (new Function(Hogan.compile(mustache_wrapper).render({template: template, compiler: compiler}) +
'; return {Hogan: Hogan, Mustache: Mustache};'))();
var Mustache = engines.Mustache;
var Hogan2 = engines.Hogan;
// sanity check
is(Mustache.hasOwnProperty('to_html'), true, 'Mustache has to_html method.');
// Check for Mustache.js partial resolution behavior.
var context = {
foo: 'bar',
mypartial: {
baz: 'qux'
}
}
var text = 'abc {{foo}} def {{>mypartial}} ghi';
var partialText = '{{baz}}';
var s = Mustache.to_html(text, context, {'mypartial': partialText});
is(s, 'abc bar def qux ghi', 'Correct emulation of Mustache.js partial-name-in-context resolution.');
// Now check to see that the Hogan resolution is unaffected.
var t = Hogan2.compile(text);
s = t.render(context, {'mypartial': partialText});
is(s, 'abc bar def ghi', 'Hogan behavior not changed by Mustache.js emulation.');
// Check for sendFun behavior
var buf = "";
function send(s) {
buf += "-FOO " + s + " FOO-";
}
var s = Mustache.to_html(text, context, {'mypartial': partialText}, send);
is(buf, '-FOO abc bar def qux ghi FOO-', 'Correct emulation of Mustache.js sendFun.');
function is(got, expected, msg) {
if (got === expected) {
output("OK: " + msg);
++passed;
} else {
output("FAIL: " + msg);
output("Expected |" + expected + "|");
output(" Got |" + got + "|");
++failed;
}
}
function complete() {
output("\nTests Complete");
output("--------------");
output("Passed: " + passed);
output("Failed: " + failed);
output("\n");
}
complete();

View File

@ -1,77 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = Hogan || require('../lib/hogan');
var doc = this["document"];
var fs = require('fs');
var passed = 0;
var failed = 0;
if (!this["output"]) {
var output = function (string) {
return doc ? doc.write(string + '<br/>') : console.log(string);
};
}
function runTest(tests) {
tests.forEach(function(test) {
var partials = {};
for (var i in test.partials) {
partials[i] = Hogan.compile(test.partials[i]);
}
var t = Hogan.compile(test.template);
if (test.data.lambda) {
var func = (new Function ('return ' + test.data.lambda.js)());
test.data.lambda = function() { return func; };
}
var s = t.render(test.data, partials);
is(s, test.expected, test.name + ': ' + test.desc);
});
}
var testDir = './test/spec/specs';
var files = fs.readdirSync(testDir)
.filter(function(f) { return f.indexOf('.json') > 0; })
.map(function(f) { return testDir + '/' + f});
for (var i = 0; i < files.length; i++) {
var test = JSON.parse(fs.readFileSync(files[i]).toString());
runTest(test.tests);
}
function is(got, expected, msg) {
if (got === expected) {
output("OK: " + msg);
++passed;
} else {
output("FAIL: " + msg);
output("Expected |" + expected + "|");
output(" Got |" + got + "|");
++failed;
}
}
function complete() {
output("\nTests Complete");
output("--------------");
output("Passed: " + passed);
output("Failed: " + failed);
output("\n");
}
complete();

View File

@ -1,31 +0,0 @@
2011-03-20: v1.1.2
Added tests for standalone tags at string boundaries.
Added tests for rendering lambda returns after delimiter changes.
2011-03-20: v1.0.3
Added tests for standalone tags at string boundaries.
Added tests for rendering lambda returns after delimiter changes.
2011-03-05: v1.1.1
Added tests for indented inline sections.
Added tests for Windows-style newlines.
2011-03-05: v1.0.2
Added tests for indented inline sections.
Added tests for Windows-style newlines.
2011-03-04: v1.1.0
Implicit iterators.
A single period (`.`) may now be used as a name in Interpolation tags,
which represents the top of stack (cast as a String).
Dotted names.
Names containing one or more periods should be resolved as chained
properties; naïvely, this is like nesting section tags, but with some
built-in scoping protections.
2011-03-02: v1.0.1
Clarifying a point in the README about version compliance.
Adding high-level documentation to each spec file.
2011-02-28: v1.0.0
Initial Release

View File

@ -1,65 +0,0 @@
The repository at https://github.com/mustache/spec is the formal standard for
Mustache. It defines both normal usage and edge-case behavior for libraries
parsing the Mustache templating language (or a superset thereof).
The specification is developed as a series of YAML files, under the `specs`
directory.
Versioning
----------
This specification is being [semantically versioned](http://semver.org).
Roughly described, major version changes will always represent backwards
incompatible changes, minor version changes will always represent new language
features and will be backwards compatible, and patch ('tiny') version changes
will always be bug fixes. For the purposes of semantic versioning, the public
API is the contents of the `specs` directory and the algorithm for testing
against it.
Mustache implementations SHOULD report the most recent version of the spec
(major and minor version numbers). If an implementation has support for any
optional modules, they SHOULD indicate so with a remark attached to the
version number (e.g. "vX.Y, including lambdas" or "v.X.Y+λ"). It is
RECOMMENDED that implementations not supporting at least v1.0.0 of this spec
refer to themselves as "Mustache-like", or "Mustache-inspired".
Alternate Formats
-----------------
Since YAML is a reasonably complex format that not every language has good
tools for working with, we also provide JSON versions of the specs on a
best-effort basis.
These should be identical to the YAML specifications, but if you find the need
to regenerate them, they can be trivially rebuilt by invoking `rake build`.
It is also worth noting that some specifications (notably, the lambda module)
rely on YAML "tags" to denote special types of data (e.g. source code). Since
JSON offers no way to denote this, a special key ("`__tag__`") is injected
with the name of the tag as its value. See `TESTING.md` for more information
about handling tagged data.
Optional Modules
----------------
Specification files beginning with a tilde (`~`) describe optional modules.
At present, the only module being described as optional is regarding support
for lambdas. As a guideline, a module may be a candidate for optionality
when:
* It does not affect the core syntax of the language.
* It does not significantly affect the output of rendered templates.
* It concerns implementation language features or data types that are not
common to or core in every targeted language.
* The lack of support by an implementation does not diminish the usage of
Mustache in the target language.
As an example, the lambda module is primarily concerned with the handling of a
particular data type (code). This is a type of data that may be difficult to
support in some languages, and users of those languages will not see the lack
as an 'inconsistency' between implementations.
Support for specific pragmas or syntax extensions, however, are best managed
outside this core specification, as adjunct specifications.
Implementors are strongly encouraged to support any and all modules they are
reasonably capable of supporting.

View File

@ -1,27 +0,0 @@
require 'json'
require 'yaml'
# Our custom YAML tags must retain their magic.
%w[ code ].each do |tag|
YAML::add_builtin_type(tag) { |_,val| val.merge(:__tag__ => tag) }
end
desc 'Build all alternate versions of the specs.'
multitask :build => [ 'build:json' ]
namespace :build do
note = 'Do not edit this file; changes belong in the appropriate YAML file.'
desc 'Build JSON versions of the specs.'
task :json do
rm(Dir['specs/*.json'], :verbose => false)
Dir.glob('specs/*.yml').each do |filename|
json_file = filename.gsub('.yml', '.json')
File.open(json_file, 'w') do |file|
doc = YAML.load_file(filename)
file << doc.merge(:__ATTN__ => note).to_json()
end
end
end
end

View File

@ -1,46 +0,0 @@
Testing your Mustache implementation against this specification should be
relatively simple. If you have a readily available testing framework on your
platform, your task may be even simpler.
In general, the process for each `.yml` file is as follows:
1. Use a YAML parser to load the file.
2. For each test in the 'tests' array:
1. Ensure that each element of the 'partials' hash (if it exists) is
stored in a place where the interpreter will look for it.
2. If your implementation will not support lambdas, feel free to skip over
the optional '~lambdas.yml' file.
2.1. If your implementation will support lambdas, ensure that each member of
'data' tagged with '!code' is properly processed into a language-
specific lambda reference.
* e.g. Given this YAML data hash:
`{ x: !code { ruby: 'proc { "x" }', perl: 'sub { "x" }' } }`
a Ruby-based Mustache implementation would process it such that it
was equivalent to this Ruby hash:
`{ 'x' => proc { "x" } }`
* If your implementation language does not currently have lambda
examples in the spec, feel free to implement them and send a pull
request.
* The JSON version of the spec represents these tagged values as a hash
with a '`__tag__`' key of 'code'.
3. Render the template (stored in the 'template' key) with the given 'data'
hash.
4. Compare the results of your rendering against the 'expected' value; any
differences should be reported, along with any useful debugging
information.
* Of note, the 'desc' key contains a rough one-line description of the
behavior being tested -- this is most useful in conjunction with the
file name and test 'name'.

View File

@ -1 +0,0 @@
{"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Comment tags represent content that should never appear in the resulting\noutput.\n\nThe tag's content may contain any substring (including newlines) EXCEPT the\nclosing delimiter.\n\nComment tags SHOULD be treated as standalone when appropriate.\n","tests":[{"name":"Inline","data":{},"expected":"1234567890","template":"12345{{! Comment Block! }}67890","desc":"Comment blocks should be removed from the template."},{"name":"Multiline","data":{},"expected":"1234567890\n","template":"12345{{!\n This is a\n multi-line comment...\n}}67890\n","desc":"Multiline comments should be permitted."},{"name":"Standalone","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n{{! Comment Block! }}\nEnd.\n","desc":"All standalone comment lines should be removed."},{"name":"Indented Standalone","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n {{! Indented Comment Block! }}\nEnd.\n","desc":"All standalone comment lines should be removed."},{"name":"Standalone Line Endings","data":{},"expected":"|\r\n|","template":"|\r\n{{! Standalone Comment }}\r\n|","desc":"\"\\r\\n\" should be considered a newline for standalone tags."},{"name":"Standalone Without Previous Line","data":{},"expected":"!","template":" {{! I'm Still Standalone }}\n!","desc":"Standalone tags should not require a newline to precede them."},{"name":"Standalone Without Newline","data":{},"expected":"!\n","template":"!\n {{! I'm Still Standalone }}","desc":"Standalone tags should not require a newline to follow them."},{"name":"Multiline Standalone","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n{{!\nSomething's going on here...\n}}\nEnd.\n","desc":"All standalone comment lines should be removed."},{"name":"Indented Multiline Standalone","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n {{!\n Something's going on here...\n }}\nEnd.\n","desc":"All standalone comment lines should be removed."},{"name":"Indented Inline","data":{},"expected":" 12 \n","template":" 12 {{! 34 }}\n","desc":"Inline comments should not strip whitespace"},{"name":"Surrounding Whitespace","data":{},"expected":"12345 67890","template":"12345 {{! Comment Block! }} 67890","desc":"Comment removal should preserve surrounding whitespace."}]}

View File

@ -1,103 +0,0 @@
overview: |
Comment tags represent content that should never appear in the resulting
output.
The tag's content may contain any substring (including newlines) EXCEPT the
closing delimiter.
Comment tags SHOULD be treated as standalone when appropriate.
tests:
- name: Inline
desc: Comment blocks should be removed from the template.
data: { }
template: '12345{{! Comment Block! }}67890'
expected: '1234567890'
- name: Multiline
desc: Multiline comments should be permitted.
data: { }
template: |
12345{{!
This is a
multi-line comment...
}}67890
expected: |
1234567890
- name: Standalone
desc: All standalone comment lines should be removed.
data: { }
template: |
Begin.
{{! Comment Block! }}
End.
expected: |
Begin.
End.
- name: Indented Standalone
desc: All standalone comment lines should be removed.
data: { }
template: |
Begin.
{{! Indented Comment Block! }}
End.
expected: |
Begin.
End.
- name: Standalone Line Endings
desc: '"\r\n" should be considered a newline for standalone tags.'
data: { }
template: "|\r\n{{! Standalone Comment }}\r\n|"
expected: "|\r\n|"
- name: Standalone Without Previous Line
desc: Standalone tags should not require a newline to precede them.
data: { }
template: " {{! I'm Still Standalone }}\n!"
expected: "!"
- name: Standalone Without Newline
desc: Standalone tags should not require a newline to follow them.
data: { }
template: "!\n {{! I'm Still Standalone }}"
expected: "!\n"
- name: Multiline Standalone
desc: All standalone comment lines should be removed.
data: { }
template: |
Begin.
{{!
Something's going on here...
}}
End.
expected: |
Begin.
End.
- name: Indented Multiline Standalone
desc: All standalone comment lines should be removed.
data: { }
template: |
Begin.
{{!
Something's going on here...
}}
End.
expected: |
Begin.
End.
- name: Indented Inline
desc: Inline comments should not strip whitespace
data: { }
template: " 12 {{! 34 }}\n"
expected: " 12 \n"
- name: Surrounding Whitespace
desc: Comment removal should preserve surrounding whitespace.
data: { }
template: '12345 {{! Comment Block! }} 67890'
expected: '12345 67890'

View File

@ -1 +0,0 @@
{"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Set Delimiter tags are used to change the tag delimiters for all content\nfollowing the tag in the current compilation unit.\n\nThe tag's content MUST be any two non-whitespace sequences (separated by\nwhitespace) EXCEPT an equals sign ('=') followed by the current closing\ndelimiter.\n\nSet Delimiter tags SHOULD be treated as standalone when appropriate.\n","tests":[{"name":"Pair Behavior","data":{"text":"Hey!"},"expected":"(Hey!)","template":"{{=<% %>=}}(<%text%>)","desc":"The equals sign (used on both sides) should permit delimiter changes."},{"name":"Special Characters","data":{"text":"It worked!"},"expected":"(It worked!)","template":"({{=[ ]=}}[text])","desc":"Characters with special meaning regexen should be valid delimiters."},{"name":"Sections","data":{"section":true,"data":"I got interpolated."},"expected":"[\n I got interpolated.\n |data|\n\n {{data}}\n I got interpolated.\n]\n","template":"[\n{{#section}}\n {{data}}\n |data|\n{{/section}}\n\n{{= | | =}}\n|#section|\n {{data}}\n |data|\n|/section|\n]\n","desc":"Delimiters set outside sections should persist."},{"name":"Inverted Sections","data":{"section":false,"data":"I got interpolated."},"expected":"[\n I got interpolated.\n |data|\n\n {{data}}\n I got interpolated.\n]\n","template":"[\n{{^section}}\n {{data}}\n |data|\n{{/section}}\n\n{{= | | =}}\n|^section|\n {{data}}\n |data|\n|/section|\n]\n","desc":"Delimiters set outside inverted sections should persist."},{"name":"Partial Inheritence","data":{"value":"yes"},"expected":"[ .yes. ]\n[ .yes. ]\n","template":"[ {{>include}} ]\n{{= | | =}}\n[ |>include| ]\n","desc":"Delimiters set in a parent template should not affect a partial.","partials":{"include":".{{value}}."}},{"name":"Post-Partial Behavior","data":{"value":"yes"},"expected":"[ .yes. .yes. ]\n[ .yes. .|value|. ]\n","template":"[ {{>include}} ]\n[ .{{value}}. .|value|. ]\n","desc":"Delimiters set in a partial should not affect the parent template.","partials":{"include":".{{value}}. {{= | | =}} .|value|."}},{"name":"Surrounding Whitespace","data":{},"expected":"| |","template":"| {{=@ @=}} |","desc":"Surrounding whitespace should be left untouched."},{"name":"Outlying Whitespace (Inline)","data":{},"expected":" | \n","template":" | {{=@ @=}}\n","desc":"Whitespace should be left untouched."},{"name":"Standalone Tag","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n{{=@ @=}}\nEnd.\n","desc":"Standalone lines should be removed from the template."},{"name":"Indented Standalone Tag","data":{},"expected":"Begin.\nEnd.\n","template":"Begin.\n {{=@ @=}}\nEnd.\n","desc":"Indented standalone lines should be removed from the template."},{"name":"Standalone Line Endings","data":{},"expected":"|\r\n|","template":"|\r\n{{= @ @ =}}\r\n|","desc":"\"\\r\\n\" should be considered a newline for standalone tags."},{"name":"Standalone Without Previous Line","data":{},"expected":"=","template":" {{=@ @=}}\n=","desc":"Standalone tags should not require a newline to precede them."},{"name":"Standalone Without Newline","data":{},"expected":"=\n","template":"=\n {{=@ @=}}","desc":"Standalone tags should not require a newline to follow them."},{"name":"Pair with Padding","data":{},"expected":"||","template":"|{{= @ @ =}}|","desc":"Superfluous in-tag whitespace should be ignored."}]}

View File

@ -1,158 +0,0 @@
overview: |
Set Delimiter tags are used to change the tag delimiters for all content
following the tag in the current compilation unit.
The tag's content MUST be any two non-whitespace sequences (separated by
whitespace) EXCEPT an equals sign ('=') followed by the current closing
delimiter.
Set Delimiter tags SHOULD be treated as standalone when appropriate.
tests:
- name: Pair Behavior
desc: The equals sign (used on both sides) should permit delimiter changes.
data: { text: 'Hey!' }
template: '{{=<% %>=}}(<%text%>)'
expected: '(Hey!)'
- name: Special Characters
desc: Characters with special meaning regexen should be valid delimiters.
data: { text: 'It worked!' }
template: '({{=[ ]=}}[text])'
expected: '(It worked!)'
- name: Sections
desc: Delimiters set outside sections should persist.
data: { section: true, data: 'I got interpolated.' }
template: |
[
{{#section}}
{{data}}
|data|
{{/section}}
{{= | | =}}
|#section|
{{data}}
|data|
|/section|
]
expected: |
[
I got interpolated.
|data|
{{data}}
I got interpolated.
]
- name: Inverted Sections
desc: Delimiters set outside inverted sections should persist.
data: { section: false, data: 'I got interpolated.' }
template: |
[
{{^section}}
{{data}}
|data|
{{/section}}
{{= | | =}}
|^section|
{{data}}
|data|
|/section|
]
expected: |
[
I got interpolated.
|data|
{{data}}
I got interpolated.
]
- name: Partial Inheritence
desc: Delimiters set in a parent template should not affect a partial.
data: { value: 'yes' }
partials:
include: '.{{value}}.'
template: |
[ {{>include}} ]
{{= | | =}}
[ |>include| ]
expected: |
[ .yes. ]
[ .yes. ]
- name: Post-Partial Behavior
desc: Delimiters set in a partial should not affect the parent template.
data: { value: 'yes' }
partials:
include: '.{{value}}. {{= | | =}} .|value|.'
template: |
[ {{>include}} ]
[ .{{value}}. .|value|. ]
expected: |
[ .yes. .yes. ]
[ .yes. .|value|. ]
# Whitespace Sensitivity
- name: Surrounding Whitespace
desc: Surrounding whitespace should be left untouched.
data: { }
template: '| {{=@ @=}} |'
expected: '| |'
- name: Outlying Whitespace (Inline)
desc: Whitespace should be left untouched.
data: { }
template: " | {{=@ @=}}\n"
expected: " | \n"
- name: Standalone Tag
desc: Standalone lines should be removed from the template.
data: { }
template: |
Begin.
{{=@ @=}}
End.
expected: |
Begin.
End.
- name: Indented Standalone Tag
desc: Indented standalone lines should be removed from the template.
data: { }
template: |
Begin.
{{=@ @=}}
End.
expected: |
Begin.
End.
- name: Standalone Line Endings
desc: '"\r\n" should be considered a newline for standalone tags.'
data: { }
template: "|\r\n{{= @ @ =}}\r\n|"
expected: "|\r\n|"
- name: Standalone Without Previous Line
desc: Standalone tags should not require a newline to precede them.
data: { }
template: " {{=@ @=}}\n="
expected: "="
- name: Standalone Without Newline
desc: Standalone tags should not require a newline to follow them.
data: { }
template: "=\n {{=@ @=}}"
expected: "=\n"
# Whitespace Insensitivity
- name: Pair with Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { }
template: '|{{= @ @ =}}|'
expected: '||'

File diff suppressed because one or more lines are too long

View File

@ -1,230 +0,0 @@
overview: |
Interpolation tags are used to integrate dynamic content into the template.
The tag's content MUST be a non-whitespace character sequence NOT containing
the current closing delimiter.
This tag's content names the data to replace the tag. A single period (`.`)
indicates that the item currently sitting atop the context stack should be
used; otherwise, name resolution is as follows:
1) Split the name on periods; the first part is the name to resolve, any
remaining parts should be retained.
2) Walk the context stack from top to bottom, finding the first context
that is a) a hash containing the name as a key OR b) an object responding
to a method with the given name.
3) If the context is a hash, the data is the value associated with the
name.
4) If the context is an object, the data is the value returned by the
method with the given name.
5) If any name parts were retained in step 1, each should be resolved
against a context stack containing only the result from the former
resolution. If any part fails resolution, the result should be considered
falsey, and should interpolate as the empty string.
Data should be coerced into a string (and escaped, if appropriate) before
interpolation.
The Interpolation tags MUST NOT be treated as standalone.
tests:
- name: No Interpolation
desc: Mustache-free templates should render as-is.
data: { }
template: |
Hello from {Mustache}!
expected: |
Hello from {Mustache}!
- name: Basic Interpolation
desc: Unadorned tags should interpolate content into the template.
data: { subject: "world" }
template: |
Hello, {{subject}}!
expected: |
Hello, world!
- name: HTML Escaping
desc: Basic interpolation should be HTML escaped.
data: { forbidden: '& " < >' }
template: |
These characters should be HTML escaped: {{forbidden}}
expected: |
These characters should be HTML escaped: &amp; &quot; &lt; &gt;
- name: Triple Mustache
desc: Triple mustaches should interpolate without HTML escaping.
data: { forbidden: '& " < >' }
template: |
These characters should not be HTML escaped: {{{forbidden}}}
expected: |
These characters should not be HTML escaped: & " < >
- name: Ampersand
desc: Ampersand should interpolate without HTML escaping.
data: { forbidden: '& " < >' }
template: |
These characters should not be HTML escaped: {{&forbidden}}
expected: |
These characters should not be HTML escaped: & " < >
- name: Basic Integer Interpolation
desc: Integers should interpolate seamlessly.
data: { mph: 85 }
template: '"{{mph}} miles an hour!"'
expected: '"85 miles an hour!"'
- name: Triple Mustache Integer Interpolation
desc: Integers should interpolate seamlessly.
data: { mph: 85 }
template: '"{{{mph}}} miles an hour!"'
expected: '"85 miles an hour!"'
- name: Ampersand Integer Interpolation
desc: Integers should interpolate seamlessly.
data: { mph: 85 }
template: '"{{&mph}} miles an hour!"'
expected: '"85 miles an hour!"'
- name: Basic Decimal Interpolation
desc: Decimals should interpolate seamlessly with proper significance.
data: { power: 1.210 }
template: '"{{power}} jiggawatts!"'
expected: '"1.21 jiggawatts!"'
- name: Triple Mustache Decimal Interpolation
desc: Decimals should interpolate seamlessly with proper significance.
data: { power: 1.210 }
template: '"{{{power}}} jiggawatts!"'
expected: '"1.21 jiggawatts!"'
- name: Ampersand Decimal Interpolation
desc: Decimals should interpolate seamlessly with proper significance.
data: { power: 1.210 }
template: '"{{&power}} jiggawatts!"'
expected: '"1.21 jiggawatts!"'
# Context Misses
- name: Basic Context Miss Interpolation
desc: Failed context lookups should default to empty strings.
data: { }
template: "I ({{cannot}}) be seen!"
expected: "I () be seen!"
- name: Triple Mustache Context Miss Interpolation
desc: Failed context lookups should default to empty strings.
data: { }
template: "I ({{{cannot}}}) be seen!"
expected: "I () be seen!"
- name: Ampersand Context Miss Interpolation
desc: Failed context lookups should default to empty strings.
data: { }
template: "I ({{&cannot}}) be seen!"
expected: "I () be seen!"
# Dotted Names
- name: Dotted Names - Basic Interpolation
desc: Dotted names should be considered a form of shorthand for sections.
data: { person: { name: 'Joe' } }
template: '"{{person.name}}" == "{{#person}}{{name}}{{/person}}"'
expected: '"Joe" == "Joe"'
- name: Dotted Names - Triple Mustache Interpolation
desc: Dotted names should be considered a form of shorthand for sections.
data: { person: { name: 'Joe' } }
template: '"{{{person.name}}}" == "{{#person}}{{{name}}}{{/person}}"'
expected: '"Joe" == "Joe"'
- name: Dotted Names - Ampersand Interpolation
desc: Dotted names should be considered a form of shorthand for sections.
data: { person: { name: 'Joe' } }
template: '"{{&person.name}}" == "{{#person}}{{&name}}{{/person}}"'
expected: '"Joe" == "Joe"'
- name: Dotted Names - Arbitrary Depth
desc: Dotted names should be functional to any level of nesting.
data:
a: { b: { c: { d: { e: { name: 'Phil' } } } } }
template: '"{{a.b.c.d.e.name}}" == "Phil"'
expected: '"Phil" == "Phil"'
- name: Dotted Names - Broken Chains
desc: Any falsey value prior to the last part of the name should yield ''.
data:
a: { }
template: '"{{a.b.c}}" == ""'
expected: '"" == ""'
- name: Dotted Names - Broken Chain Resolution
desc: Each part of a dotted name should resolve only against its parent.
data:
a: { b: { } }
c: { name: 'Jim' }
template: '"{{a.b.c.name}}" == ""'
expected: '"" == ""'
- name: Dotted Names - Initial Resolution
desc: The first part of a dotted name should resolve as any other name.
data:
a: { b: { c: { d: { e: { name: 'Phil' } } } } }
b: { c: { d: { e: { name: 'Wrong' } } } }
template: '"{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil"'
expected: '"Phil" == "Phil"'
# Whitespace Sensitivity
- name: Interpolation - Surrounding Whitespace
desc: Interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: '| {{string}} |'
expected: '| --- |'
- name: Triple Mustache - Surrounding Whitespace
desc: Interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: '| {{{string}}} |'
expected: '| --- |'
- name: Ampersand - Surrounding Whitespace
desc: Interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: '| {{&string}} |'
expected: '| --- |'
- name: Interpolation - Standalone
desc: Standalone interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: " {{string}}\n"
expected: " ---\n"
- name: Triple Mustache - Standalone
desc: Standalone interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: " {{{string}}}\n"
expected: " ---\n"
- name: Ampersand - Standalone
desc: Standalone interpolation should not alter surrounding whitespace.
data: { string: '---' }
template: " {{&string}}\n"
expected: " ---\n"
# Whitespace Insensitivity
- name: Interpolation With Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { string: "---" }
template: '|{{ string }}|'
expected: '|---|'
- name: Triple Mustache With Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { string: "---" }
template: '|{{{ string }}}|'
expected: '|---|'
- name: Ampersand With Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { string: "---" }
template: '|{{& string }}|'
expected: '|---|'

File diff suppressed because one or more lines are too long

View File

@ -1,193 +0,0 @@
overview: |
Inverted Section tags and End Section tags are used in combination to wrap a
section of the template.
These tags' content MUST be a non-whitespace character sequence NOT
containing the current closing delimiter; each Inverted Section tag MUST be
followed by an End Section tag with the same content within the same
section.
This tag's content names the data to replace the tag. Name resolution is as
follows:
1) Split the name on periods; the first part is the name to resolve, any
remaining parts should be retained.
2) Walk the context stack from top to bottom, finding the first context
that is a) a hash containing the name as a key OR b) an object responding
to a method with the given name.
3) If the context is a hash, the data is the value associated with the
name.
4) If the context is an object and the method with the given name has an
arity of 1, the method SHOULD be called with a String containing the
unprocessed contents of the sections; the data is the value returned.
5) Otherwise, the data is the value returned by calling the method with
the given name.
6) If any name parts were retained in step 1, each should be resolved
against a context stack containing only the result from the former
resolution. If any part fails resolution, the result should be considered
falsey, and should interpolate as the empty string.
If the data is not of a list type, it is coerced into a list as follows: if
the data is truthy (e.g. `!!data == true`), use a single-element list
containing the data, otherwise use an empty list.
This section MUST NOT be rendered unless the data list is empty.
Inverted Section and End Section tags SHOULD be treated as standalone when
appropriate.
tests:
- name: Falsey
desc: Falsey sections should have their contents rendered.
data: { boolean: false }
template: '"{{^boolean}}This should be rendered.{{/boolean}}"'
expected: '"This should be rendered."'
- name: Truthy
desc: Truthy sections should have their contents omitted.
data: { boolean: true }
template: '"{{^boolean}}This should not be rendered.{{/boolean}}"'
expected: '""'
- name: Context
desc: Objects and hashes should behave like truthy values.
data: { context: { name: 'Joe' } }
template: '"{{^context}}Hi {{name}}.{{/context}}"'
expected: '""'
- name: List
desc: Lists should behave like truthy values.
data: { list: [ { n: 1 }, { n: 2 }, { n: 3 } ] }
template: '"{{^list}}{{n}}{{/list}}"'
expected: '""'
- name: Empty List
desc: Empty lists should behave like falsey values.
data: { list: [ ] }
template: '"{{^list}}Yay lists!{{/list}}"'
expected: '"Yay lists!"'
- name: Doubled
desc: Multiple inverted sections per template should be permitted.
data: { bool: false, two: 'second' }
template: |
{{^bool}}
* first
{{/bool}}
* {{two}}
{{^bool}}
* third
{{/bool}}
expected: |
* first
* second
* third
- name: Nested (Falsey)
desc: Nested falsey sections should have their contents rendered.
data: { bool: false }
template: "| A {{^bool}}B {{^bool}}C{{/bool}} D{{/bool}} E |"
expected: "| A B C D E |"
- name: Nested (Truthy)
desc: Nested truthy sections should be omitted.
data: { bool: true }
template: "| A {{^bool}}B {{^bool}}C{{/bool}} D{{/bool}} E |"
expected: "| A E |"
- name: Context Misses
desc: Failed context lookups should be considered falsey.
data: { }
template: "[{{^missing}}Cannot find key 'missing'!{{/missing}}]"
expected: "[Cannot find key 'missing'!]"
# Dotted Names
- name: Dotted Names - Truthy
desc: Dotted names should be valid for Inverted Section tags.
data: { a: { b: { c: true } } }
template: '"{{^a.b.c}}Not Here{{/a.b.c}}" == ""'
expected: '"" == ""'
- name: Dotted Names - Falsey
desc: Dotted names should be valid for Inverted Section tags.
data: { a: { b: { c: false } } }
template: '"{{^a.b.c}}Not Here{{/a.b.c}}" == "Not Here"'
expected: '"Not Here" == "Not Here"'
- name: Dotted Names - Broken Chains
desc: Dotted names that cannot be resolved should be considered falsey.
data: { a: { } }
template: '"{{^a.b.c}}Not Here{{/a.b.c}}" == "Not Here"'
expected: '"Not Here" == "Not Here"'
# Whitespace Sensitivity
- name: Surrounding Whitespace
desc: Inverted sections should not alter surrounding whitespace.
data: { boolean: false }
template: " | {{^boolean}}\t|\t{{/boolean}} | \n"
expected: " | \t|\t | \n"
- name: Internal Whitespace
desc: Inverted should not alter internal whitespace.
data: { boolean: false }
template: " | {{^boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n"
expected: " | \n | \n"
- name: Indented Inline Sections
desc: Single-line sections should not alter surrounding whitespace.
data: { boolean: false }
template: " {{^boolean}}NO{{/boolean}}\n {{^boolean}}WAY{{/boolean}}\n"
expected: " NO\n WAY\n"
- name: Standalone Lines
desc: Standalone lines should be removed from the template.
data: { boolean: false }
template: |
| This Is
{{^boolean}}
|
{{/boolean}}
| A Line
expected: |
| This Is
|
| A Line
- name: Standalone Indented Lines
desc: Standalone indented lines should be removed from the template.
data: { boolean: false }
template: |
| This Is
{{^boolean}}
|
{{/boolean}}
| A Line
expected: |
| This Is
|
| A Line
- name: Standalone Line Endings
desc: '"\r\n" should be considered a newline for standalone tags.'
data: { boolean: false }
template: "|\r\n{{^boolean}}\r\n{{/boolean}}\r\n|"
expected: "|\r\n|"
- name: Standalone Without Previous Line
desc: Standalone tags should not require a newline to precede them.
data: { boolean: false }
template: " {{^boolean}}\n^{{/boolean}}\n/"
expected: "^\n/"
- name: Standalone Without Newline
desc: Standalone tags should not require a newline to follow them.
data: { boolean: false }
template: "^{{^boolean}}\n/\n {{/boolean}}"
expected: "^\n/\n"
# Whitespace Insensitivity
- name: Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { boolean: false }
template: '|{{^ boolean }}={{/ boolean }}|'
expected: '|=|'

View File

@ -1 +0,0 @@
{"__ATTN__":"Do not edit this file; changes belong in the appropriate YAML file.","overview":"Partial tags are used to expand an external template into the current\ntemplate.\n\nThe tag's content MUST be a non-whitespace character sequence NOT containing\nthe current closing delimiter.\n\nThis tag's content names the partial to inject. Set Delimiter tags MUST NOT\naffect the parsing of a partial. The partial MUST be rendered against the\ncontext stack local to the tag. If the named partial cannot be found, the\nempty string SHOULD be used instead, as in interpolations.\n\nPartial tags SHOULD be treated as standalone when appropriate. If this tag\nis used standalone, any whitespace preceding the tag should treated as\nindentation, and prepended to each line of the partial before rendering.\n","tests":[{"name":"Basic Behavior","data":{},"expected":"\"from partial\"","template":"\"{{>text}}\"","desc":"The greater-than operator should expand to the named partial.","partials":{"text":"from partial"}},{"name":"Failed Lookup","data":{},"expected":"\"\"","template":"\"{{>text}}\"","desc":"The empty string should be used when the named partial is not found.","partials":{}},{"name":"Context","data":{"text":"content"},"expected":"\"*content*\"","template":"\"{{>partial}}\"","desc":"The greater-than operator should operate within the current context.","partials":{"partial":"*{{text}}*"}},{"name":"Recursion","data":{"content":"X","nodes":[{"content":"Y","nodes":[]}]},"expected":"X<Y<>>","template":"{{>node}}","desc":"The greater-than operator should properly recurse.","partials":{"node":"{{content}}<{{#nodes}}{{>node}}{{/nodes}}>"}},{"name":"Surrounding Whitespace","data":{},"expected":"| \t|\t |","template":"| {{>partial}} |","desc":"The greater-than operator should not alter surrounding whitespace.","partials":{"partial":"\t|\t"}},{"name":"Inline Indentation","data":{"data":"|"},"expected":" | >\n>\n","template":" {{data}} {{> partial}}\n","desc":"Whitespace should be left untouched.","partials":{"partial":">\n>"}},{"name":"Standalone Line Endings","data":{},"expected":"|\r\n>|","template":"|\r\n{{>partial}}\r\n|","desc":"\"\\r\\n\" should be considered a newline for standalone tags.","partials":{"partial":">"}},{"name":"Standalone Without Previous Line","data":{},"expected":" >\n >>","template":" {{>partial}}\n>","desc":"Standalone tags should not require a newline to precede them.","partials":{"partial":">\n>"}},{"name":"Standalone Without Newline","data":{},"expected":">\n >\n >","template":">\n {{>partial}}","desc":"Standalone tags should not require a newline to follow them.","partials":{"partial":">\n>"}},{"name":"Standalone Indentation","data":{"content":"<\n->"},"expected":"\\\n |\n <\n->\n |\n/\n","template":"\\\n {{>partial}}\n/\n","desc":"Each line of the partial should be indented before rendering.","partials":{"partial":"|\n{{{content}}}\n|\n"}},{"name":"Padding Whitespace","data":{"boolean":true},"expected":"|[]|","template":"|{{> partial }}|","desc":"Superfluous in-tag whitespace should be ignored.","partials":{"partial":"[]"}}]}

View File

@ -1,109 +0,0 @@
overview: |
Partial tags are used to expand an external template into the current
template.
The tag's content MUST be a non-whitespace character sequence NOT containing
the current closing delimiter.
This tag's content names the partial to inject. Set Delimiter tags MUST NOT
affect the parsing of a partial. The partial MUST be rendered against the
context stack local to the tag. If the named partial cannot be found, the
empty string SHOULD be used instead, as in interpolations.
Partial tags SHOULD be treated as standalone when appropriate. If this tag
is used standalone, any whitespace preceding the tag should treated as
indentation, and prepended to each line of the partial before rendering.
tests:
- name: Basic Behavior
desc: The greater-than operator should expand to the named partial.
data: { }
template: '"{{>text}}"'
partials: { text: 'from partial' }
expected: '"from partial"'
- name: Failed Lookup
desc: The empty string should be used when the named partial is not found.
data: { }
template: '"{{>text}}"'
partials: { }
expected: '""'
- name: Context
desc: The greater-than operator should operate within the current context.
data: { text: 'content' }
template: '"{{>partial}}"'
partials: { partial: '*{{text}}*' }
expected: '"*content*"'
- name: Recursion
desc: The greater-than operator should properly recurse.
data: { content: "X", nodes: [ { content: "Y", nodes: [] } ] }
template: '{{>node}}'
partials: { node: '{{content}}<{{#nodes}}{{>node}}{{/nodes}}>' }
expected: 'X<Y<>>'
# Whitespace Sensitivity
- name: Surrounding Whitespace
desc: The greater-than operator should not alter surrounding whitespace.
data: { }
template: '| {{>partial}} |'
partials: { partial: "\t|\t" }
expected: "| \t|\t |"
- name: Inline Indentation
desc: Whitespace should be left untouched.
data: { data: '|' }
template: " {{data}} {{> partial}}\n"
partials: { partial: ">\n>" }
expected: " | >\n>\n"
- name: Standalone Line Endings
desc: '"\r\n" should be considered a newline for standalone tags.'
data: { }
template: "|\r\n{{>partial}}\r\n|"
partials: { partial: ">" }
expected: "|\r\n>|"
- name: Standalone Without Previous Line
desc: Standalone tags should not require a newline to precede them.
data: { }
template: " {{>partial}}\n>"
partials: { partial: ">\n>"}
expected: " >\n >>"
- name: Standalone Without Newline
desc: Standalone tags should not require a newline to follow them.
data: { }
template: ">\n {{>partial}}"
partials: { partial: ">\n>" }
expected: ">\n >\n >"
- name: Standalone Indentation
desc: Each line of the partial should be indented before rendering.
data: { content: "<\n->" }
template: |
\
{{>partial}}
/
partials:
partial: |
|
{{{content}}}
|
expected: |
\
|
<
->
|
/
# Whitespace Insensitivity
- name: Padding Whitespace
desc: Superfluous in-tag whitespace should be ignored.
data: { boolean: true }
template: "|{{> partial }}|"
partials: { partial: "[]" }
expected: '|[]|'

File diff suppressed because one or more lines are too long

View File

@ -1,256 +0,0 @@
overview: |
Section tags and End Section tags are used in combination to wrap a section
of the template for iteration
These tags' content MUST be a non-whitespace character sequence NOT
containing the current closing delimiter; each Section tag MUST be followed
by an End Section tag with the same content within the same section.
This tag's content names the data to replace the tag. Name resolution is as
follows:
1) Split the name on periods; the first part is the name to resolve, any
remaining parts should be retained.
2) Walk the context stack from top to bottom, finding the first context
that is a) a hash containing the name as a key OR b) an object responding
to a method with the given name.
3) If the context is a hash, the data is the value associated with the
name.
4) If the context is an object and the method with the given name has an
arity of 1, the method SHOULD be called with a String containing the
unprocessed contents of the sections; the data is the value returned.
5) Otherwise, the data is the value returned by calling the method with
the given name.
6) If any name parts were retained in step 1, each should be resolved
against a context stack containing only the result from the former
resolution. If any part fails resolution, the result should be considered
falsey, and should interpolate as the empty string.
If the data is not of a list type, it is coerced into a list as follows: if
the data is truthy (e.g. `!!data == true`), use a single-element list
containing the data, otherwise use an empty list.
For each element in the data list, the element MUST be pushed onto the
context stack, the section MUST be rendered, and the element MUST be popped
off the context stack.
Section and End Section tags SHOULD be treated as standalone when
appropriate.
tests:
- name: Truthy
desc: Truthy sections should have their contents rendered.
data: { boolean: true }
template: '"{{#boolean}}This should be rendered.{{/boolean}}"'
expected: '"This should be rendered."'
- name: Falsey
desc: Falsey sections should have their contents omitted.
data: { boolean: false }
template: '"{{#boolean}}This should not be rendered.{{/boolean}}"'
expected: '""'
- name: Context
desc: Objects and hashes should be pushed onto the context stack.
data: { context: { name: 'Joe' } }
template: '"{{#context}}Hi {{name}}.{{/context}}"'
expected: '"Hi Joe."'
- name: Deeply Nested Contexts
desc: All elements on the context stack should be accessible.
data:
a: { one: 1 }
b: { two: 2 }
c: { three: 3 }
d: { four: 4 }
e: { five: 5 }
template: |
{{#a}}
{{one}}
{{#b}}
{{one}}{{two}}{{one}}
{{#c}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{#d}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{#e}}
{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
{{/e}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{/d}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{/c}}
{{one}}{{two}}{{one}}
{{/b}}
{{one}}
{{/a}}
expected: |
1
121
12321
1234321
123454321
1234321
12321
121
1
- name: List
desc: Lists should be iterated; list items should visit the context stack.
data: { list: [ { item: 1 }, { item: 2 }, { item: 3 } ] }
template: '"{{#list}}{{item}}{{/list}}"'
expected: '"123"'
- name: Empty List
desc: Empty lists should behave like falsey values.
data: { list: [ ] }
template: '"{{#list}}Yay lists!{{/list}}"'
expected: '""'
- name: Doubled
desc: Multiple sections per template should be permitted.
data: { bool: true, two: 'second' }
template: |
{{#bool}}
* first
{{/bool}}
* {{two}}
{{#bool}}
* third
{{/bool}}
expected: |
* first
* second
* third
- name: Nested (Truthy)
desc: Nested truthy sections should have their contents rendered.
data: { bool: true }
template: "| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |"
expected: "| A B C D E |"
- name: Nested (Falsey)
desc: Nested falsey sections should be omitted.
data: { bool: false }
template: "| A {{#bool}}B {{#bool}}C{{/bool}} D{{/bool}} E |"
expected: "| A E |"
- name: Context Misses
desc: Failed context lookups should be considered falsey.
data: { }
template: "[{{#missing}}Found key 'missing'!{{/missing}}]"
expected: "[]"
# Implicit Iterators
- name: Implicit Iterator - String
desc: Implicit iterators should directly interpolate strings.
data:
list: [ 'a', 'b', 'c', 'd', 'e' ]
template: '"{{#list}}({{.}}){{/list}}"'
expected: '"(a)(b)(c)(d)(e)"'
- name: Implicit Iterator - Integer
desc: Implicit iterators should cast integers to strings and interpolate.
data:
list: [ 1, 2, 3, 4, 5 ]
template: '"{{#list}}({{.}}){{/list}}"'
expected: '"(1)(2)(3)(4)(5)"'
- name: Implicit Iterator - Decimal
desc: Implicit iterators should cast decimals to strings and interpolate.
data:
list: [ 1.10, 2.20, 3.30, 4.40, 5.50 ]
template: '"{{#list}}({{.}}){{/list}}"'
expected: '"(1.1)(2.2)(3.3)(4.4)(5.5)"'
# Dotted Names
- name: Dotted Names - Truthy
desc: Dotted names should be valid for Section tags.
data: { a: { b: { c: true } } }
template: '"{{#a.b.c}}Here{{/a.b.c}}" == "Here"'
expected: '"Here" == "Here"'
- name: Dotted Names - Falsey
desc: Dotted names should be valid for Section tags.
data: { a: { b: { c: false } } }
template: '"{{#a.b.c}}Here{{/a.b.c}}" == ""'
expected: '"" == ""'
- name: Dotted Names - Broken Chains
desc: Dotted names that cannot be resolved should be considered falsey.
data: { a: { } }
template: '"{{#a.b.c}}Here{{/a.b.c}}" == ""'
expected: '"" == ""'
# Whitespace Sensitivity
- name: Surrounding Whitespace
desc: Sections should not alter surrounding whitespace.
data: { boolean: true }
template: " | {{#boolean}}\t|\t{{/boolean}} | \n"
expected: " | \t|\t | \n"
- name: Internal Whitespace
desc: Sections should not alter internal whitespace.
data: { boolean: true }
template: " | {{#boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n"
expected: " | \n | \n"
- name: Indented Inline Sections
desc: Single-line sections should not alter surrounding whitespace.
data: { boolean: true }
template: " {{#boolean}}YES{{/boolean}}\n {{#boolean}}GOOD{{/boolean}}\n"
expected: " YES\n GOOD\n"
- name: Standalone Lines
desc: Standalone lines should be removed from the template.
data: { boolean: true }
template: |
| This Is
{{#boolean}}
|
{{/boolean}}
| A Line
expected: |
| This Is
|
| A Line
- name: Indented Standalone Lines
desc: Indented standalone lines should be removed from the template.
data: { boolean: true }
template: |
| This Is
{{#boolean}}
|
{{/boolean}}
| A Line
expected: |
| This Is
|
| A Line
- name: Standalone Line Endings
desc: '"\r\n" should be considered a newline for standalone tags.'
data: { boolean: true }
template: "|\r\n{{#boolean}}\r\n{{/boolean}}\r\n|"
expected: "|\r\n|"
- name: Standalone Without Previous Line
desc: Standalone tags should not require a newline to precede them.
data: { boolean: true }
template: " {{#boolean}}\n#{{/boolean}}\n/"
expected: "#\n/"
- name: Standalone Without Newline
desc: Standalone tags should not require a newline to follow them.
data: { boolean: true }
template: "#{{#boolean}}\n/\n {{/boolean}}"
expected: "#\n/\n"
# Whitespace Insensitivity
- name: Padding
desc: Superfluous in-tag whitespace should be ignored.
data: { boolean: true }
template: '|{{# boolean }}={{/ boolean }}|'
expected: '|=|'

File diff suppressed because one or more lines are too long

View File

@ -1,149 +0,0 @@
overview: |
Lambdas are a special-cased data type for use in interpolations and
sections.
When used as the data value for an Interpolation tag, the lambda MUST be
treatable as an arity 0 function, and invoked as such. The returned value
MUST be rendered against the default delimiters, then interpolated in place
of the lambda.
When used as the data value for a Section tag, the lambda MUST be treatable
as an arity 1 function, and invoked as such (passing a String containing the
unprocessed section contents). The returned value MUST be rendered against
the current delimiters, then interpolated in place of the section.
tests:
- name: Interpolation
desc: A lambda's return value should be interpolated.
data:
lambda: !code
ruby: 'proc { "world" }'
perl: 'sub { "world" }'
js: 'function() { return "world" }'
php: 'return "world";'
python: 'lambda: "world"'
clojure: '(fn [] "world")'
template: "Hello, {{lambda}}!"
expected: "Hello, world!"
- name: Interpolation - Expansion
desc: A lambda's return value should be parsed.
data:
planet: "world"
lambda: !code
ruby: 'proc { "{{planet}}" }'
perl: 'sub { "{{planet}}" }'
js: 'function() { return "{{planet}}" }'
php: 'return "{{planet}}";'
python: 'lambda: "{{planet}}"'
clojure: '(fn [] "{{planet}}")'
template: "Hello, {{lambda}}!"
expected: "Hello, world!"
- name: Interpolation - Alternate Delimiters
desc: A lambda's return value should parse with the default delimiters.
data:
planet: "world"
lambda: !code
ruby: 'proc { "|planet| => {{planet}}" }'
perl: 'sub { "|planet| => {{planet}}" }'
js: 'function() { return "|planet| => {{planet}}" }'
php: 'return "|planet| => {{planet}}";'
python: 'lambda: "|planet| => {{planet}}"'
clojure: '(fn [] "|planet| => {{planet}}")'
template: "{{= | | =}}\nHello, (|&lambda|)!"
expected: "Hello, (|planet| => world)!"
- name: Interpolation - Multiple Calls
desc: Interpolated lambdas should not be cached.
data:
lambda: !code
ruby: 'proc { $calls ||= 0; $calls += 1 }'
perl: 'sub { no strict; $calls += 1 }'
js: 'function() { return (g=(function(){return this})()).calls=(g.calls||0)+1 }'
php: 'global $calls; return ++$calls;'
python: 'lambda: globals().update(calls=globals().get("calls",0)+1) or calls'
clojure: '(def g (atom 0)) (fn [] (swap! g inc))'
template: '{{lambda}} == {{{lambda}}} == {{lambda}}'
expected: '1 == 2 == 3'
- name: Escaping
desc: Lambda results should be appropriately escaped.
data:
lambda: !code
ruby: 'proc { ">" }'
perl: 'sub { ">" }'
js: 'function() { return ">" }'
php: 'return ">";'
python: 'lambda: ">"'
clojure: '(fn [] ">")'
template: "<{{lambda}}{{{lambda}}}"
expected: "<&gt;>"
- name: Section
desc: Lambdas used for sections should receive the raw section string.
data:
x: 'Error!'
lambda: !code
ruby: 'proc { |text| text == "{{x}}" ? "yes" : "no" }'
perl: 'sub { $_[0] eq "{{x}}" ? "yes" : "no" }'
js: 'function(txt) { return (txt == "{{x}}" ? "yes" : "no") }'
php: 'return ($text == "{{x}}") ? "yes" : "no";'
python: 'lambda text: text == "{{x}}" and "yes" or "no"'
clojure: '(fn [text] (if (= text "{{x}}") "yes" "no"))'
template: "<{{#lambda}}{{x}}{{/lambda}}>"
expected: "<yes>"
- name: Section - Expansion
desc: Lambdas used for sections should have their results parsed.
data:
planet: "Earth"
lambda: !code
ruby: 'proc { |text| "#{text}{{planet}}#{text}" }'
perl: 'sub { $_[0] . "{{planet}}" . $_[0] }'
js: 'function(txt) { return txt + "{{planet}}" + txt }'
php: 'return $text . "{{planet}}" . $text;'
python: 'lambda text: "%s{{planet}}%s" % (text, text)'
clojure: '(fn [text] (str text "{{planet}}" text))'
template: "<{{#lambda}}-{{/lambda}}>"
expected: "<-Earth->"
- name: Section - Alternate Delimiters
desc: Lambdas used for sections should parse with the current delimiters.
data:
planet: "Earth"
lambda: !code
ruby: 'proc { |text| "#{text}{{planet}} => |planet|#{text}" }'
perl: 'sub { $_[0] . "{{planet}} => |planet|" . $_[0] }'
js: 'function(txt) { return txt + "{{planet}} => |planet|" + txt }'
php: 'return $text . "{{planet}} => |planet|" . $text;'
python: 'lambda text: "%s{{planet}} => |planet|%s" % (text, text)'
clojure: '(fn [text] (str text "{{planet}} => |planet|" text))'
template: "{{= | | =}}<|#lambda|-|/lambda|>"
expected: "<-{{planet}} => Earth->"
- name: Section - Multiple Calls
desc: Lambdas used for sections should not be cached.
data:
lambda: !code
ruby: 'proc { |text| "__#{text}__" }'
perl: 'sub { "__" . $_[0] . "__" }'
js: 'function(txt) { return "__" + txt + "__" }'
php: 'return "__" . $text . "__";'
python: 'lambda text: "__%s__" % (text)'
clojure: '(fn [text] (str "__" text "__"))'
template: '{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}'
expected: '__FILE__ != __LINE__'
- name: Inverted Section
desc: Lambdas used for inverted sections should be considered truthy.
data:
static: 'static'
lambda: !code
ruby: 'proc { |text| false }'
perl: 'sub { 0 }'
js: 'function(txt) { return false }'
php: 'return false;'
python: 'lambda text: 0'
clojure: '(fn [text] false)'
template: "<{{^lambda}}{{static}}{{/lambda}}>"
expected: "<>"

View File

@ -1,8 +0,0 @@
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

View File

@ -1,74 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var fs = require('fs');
var path = require('path');
var Hogan = require(__dirname + '/../lib/hogan');
var minlicense = '/**\n* @preserve Copyright 2012 Twitter, Inc.\n* @license http://www.apache.org/licenses/LICENSE-2.0.txt\n*/\n';
function read(path) {
return fs.readFileSync(path).toString()
}
// Good enough for little js files
function copy(src, dst) {
return fs.writeFileSync(dst, read(src));
}
function uglify(src, dst) {
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;
var orig_code = read(src);
var ast = jsp.parse(orig_code); // parse code and get the initial AST
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
fs.writeFileSync(dst, minlicense + pro.gen_code(ast));
}
var packageJSON = JSON.parse(read('package.json'));
var version = packageJSON.version.substring(0, packageJSON.version.indexOf('-'));
function removeFirstComment(text) {
return text.substring(text.indexOf('*/') + 2);
}
var context = {
template: removeFirstComment(read(__dirname + '/../lib/template.js')),
compiler: removeFirstComment(read(__dirname + '/../lib/compiler.js'))
};
var wrapperPath = '/../wrappers/';
var wrappers = fs.readdirSync(__dirname + wrapperPath).map(function(f) {
return __dirname + wrapperPath + f;
});
var distPath = __dirname + '/../dist/';
wrappers.forEach(function(wrapper) {
var tail = path.basename(wrapper, '.mustache');
var target = distPath + 'hogan-' + version + '.' + tail;
var uglified = distPath + 'hogan-' + version + '.min.' + tail;
fs.writeFileSync(target, Hogan.compile(read(wrapper)).render(context));
uglify(target, uglified);
});
// Also release Hogan.Template on its own.
var templateTarget = distPath + 'template-' + version + '.js';
fs.writeFileSync(templateTarget, read(__dirname + '/../lib/template.js'));
uglify(templateTarget, distPath + 'template-' + version + '.min.js');
// Add packageJSON to node distribution
packageJSON.version = version;
fs.writeFileSync(__dirname + '/../dist/nodejs/package.json',
JSON.stringify(packageJSON, null, " "));

View File

@ -1,32 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = require(__dirname + '/../lib/hogan.js');
var fs = require('fs');
var path = require('path');
// Substitute variables in the homepage with values from package.json
var homeTemplatePath = __dirname + '/../build/gh-pages/index.html.mustache';
var contextPath = __dirname + '/../dist/nodejs/package.json';
var homepage = fs.readFileSync(homeTemplatePath).toString();
var context = JSON.parse(fs.readFileSync(contextPath).toString());
var template = Hogan.compile(homepage);
fs.writeFileSync(path.dirname(homeTemplatePath) + '/index.html',
template.render(context));
fs.unlinkSync(homeTemplatePath);

View File

@ -1,500 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var HoganTemplate = (function () {
function constructor(text) {
this.text = text;
};
constructor.prototype = {
// render: replaced by generated code.
r: function (context, partials) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials) {
return this.r(context, partials);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
return partial.render(context, partials);
},
// render a section
rs: function(context, partials, section) {
var buf = '';
var tail = context[context.length - 1];
if (!isArray(tail)) {
buf = section(context, partials);
return buf;
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end) {
if (isArray(val) && val.length === 0) {
return false;
}
if (!inverted && typeof val == 'function') {
val = this.ls(val, ctx, partials, start, end);
}
var pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
var names = key.split('.');
var val = this.f(names[0], ctx, partials, returnFound);
var cx = null;
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false;
var v = null;
var found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text) {
var t = val.call(cx, text, function(t) {
return Hogan.compile(t).render(cx);
});
var s = Hogan.compile(t.toString()).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, start, end) {
var cx = ctx[ctx.length - 1];
if (val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end));
}
var t = val.call(cx);
if (typeof t == 'function') {
return this.ho(t, cx, partials, this.text.substring(start, end));
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
return Hogan.compile(val.call(cx).toString()).render(cx, partials);
}
};
var rAmp = /&/g, rLt = /</g, rGt = />/g, rApos =/\'/g,
rQuot = /\"/g, hChars =/[&<>\"\']/;
function hoganEscape(str) {
var s = String(str === null ? '' : str);
return hChars.test(s) ? s.replace(rAmp,'&amp;')
.replace(rLt,'&lt;').replace(rGt,'&gt;')
.replace(rApos,'&#39;').replace(rQuot, '&quot;') : s;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
}
return constructor;
})();
var Hogan = (function () {
function scan(text) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) == null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart; j < tokens.length; j++) {
if (!tokens[j].tag) {
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'})
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag;
var closeIndex = text.indexOf(close, index);
var delimiters = trim(text.substring(text.indexOf('=', index) + 1,
closeIndex)).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text[i] == '\n') {
filterLine(seenTag);
} else {
buf += text[i];
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
var tag = tagTypes[text[i + 1]];
tagType = tag ? text[i + 1] : '_v';
seenTag = i;
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
} else {
if (tagChange(ctag, text, i)) {
i += ctag.length - 1;
tokens.push({tag: tagType, n: trim(buf),
i: (tagType == '/') ? seenTag - 1 : i + 1});
buf = '';
state = IN_TEXT;
if (tagType == '{') {
i++;
}
} else {
buf += text[i];
}
}
}
filterLine(seenTag, true);
return tokens;
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/;
var tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
function tagChange(tag, text, index) {
if (text[index] != tag[0]) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text[index + i] != tag[i]) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' ||
isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length == 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function generate(tree, text, options) {
var code = 'var c = [cx];var b = "";var _ = this;' +
walk(tree) + 'return b;';
if (options.asString) {
return 'function(cx,p){' + code + ';};';
}
var template = new HoganTemplate(text);
template.r = new Function('cx', 'p', code);
return template;
}
var rQuot = /\"/g, rNewline = /\n/g, rCr = /\r/g, rSlash = /\\/g;
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r')
};
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i].n);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('\n');
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text(tree[i]);
}
}
return code;
}
function section(nodes, id, method, start, end) {
var code = 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),';
code += 'c,p,0,' + start + ',' + end + ')){';
code += 'b += _.rs(c,p,';
code += 'function(c,p){ var b = "";';
code += walk(nodes);
code += 'return b;});c.pop();}';
code += 'else{b += _.b; _.b = ""};';
return code;
}
function invertedSection(nodes, id, method) {
var code = 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0)){';
code += walk(nodes);
code += '};';
return code;
}
function partial(id) {
return 'b += _.rp("' + esc(id) + '",c[c.length - 1],p);';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += "' + esc(id) + '";';
}
return ({
scan: scan,
parse: function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
cache: {},
compile: function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
options = options || {};
var t = this.cache[text];
if (t) {
return t;
}
t = generate(this.parse(scan(text), options), text, options);
return this.cache[text] = t;
}
});
})();
// Export the hogan constructor for Node.js and CommonJS.
if (typeof module !== 'undefined' && module.exports) {
module.exports = Hogan;
module.exports.Template = HoganTemplate;
} else if (typeof exports !== 'undefined') {
exports.Hogan = Hogan;
exports.HoganTemplate = HoganTemplate;
}

File diff suppressed because one or more lines are too long

View File

@ -1,500 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var HoganTemplate = (function () {
function constructor(text) {
this.text = text;
};
constructor.prototype = {
// render: replaced by generated code.
r: function (context, partials) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials) {
return this.r(context, partials);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
return partial.render(context, partials);
},
// render a section
rs: function(context, partials, section) {
var buf = '';
var tail = context[context.length - 1];
if (!isArray(tail)) {
buf = section(context, partials);
return buf;
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end) {
if (isArray(val) && val.length === 0) {
return false;
}
if (!inverted && typeof val == 'function') {
val = this.ls(val, ctx, partials, start, end);
}
var pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
var names = key.split('.');
var val = this.f(names[0], ctx, partials, returnFound);
var cx = null;
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false;
var v = null;
var found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text) {
var t = val.call(cx, text, function(t) {
return Hogan.compile(t).render(cx);
});
var s = Hogan.compile(t.toString()).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, start, end) {
var cx = ctx[ctx.length - 1];
if (val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end));
}
var t = val.call(cx);
if (typeof t == 'function') {
return this.ho(t, cx, partials, this.text.substring(start, end));
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
return Hogan.compile(val.call(cx).toString()).render(cx, partials);
}
};
var rAmp = /&/g, rLt = /</g, rGt = />/g, rApos =/\'/g,
rQuot = /\"/g, hChars =/[&<>\"\']/;
function hoganEscape(str) {
var s = String(str === null ? '' : str);
return hChars.test(s) ? s.replace(rAmp,'&amp;')
.replace(rLt,'&lt;').replace(rGt,'&gt;')
.replace(rApos,'&#39;').replace(rQuot, '&quot;') : s;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
}
return constructor;
})();
var Hogan = (function () {
function scan(text) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) == null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart; j < tokens.length; j++) {
if (!tokens[j].tag) {
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'})
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag;
var closeIndex = text.indexOf(close, index);
var delimiters = trim(text.substring(text.indexOf('=', index) + 1,
closeIndex)).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text[i] == '\n') {
filterLine(seenTag);
} else {
buf += text[i];
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
var tag = tagTypes[text[i + 1]];
tagType = tag ? text[i + 1] : '_v';
seenTag = i;
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
} else {
if (tagChange(ctag, text, i)) {
i += ctag.length - 1;
tokens.push({tag: tagType, n: trim(buf),
i: (tagType == '/') ? seenTag - 1 : i + 1});
buf = '';
state = IN_TEXT;
if (tagType == '{') {
i++;
}
} else {
buf += text[i];
}
}
}
filterLine(seenTag, true);
return tokens;
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/;
var tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
function tagChange(tag, text, index) {
if (text[index] != tag[0]) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text[index + i] != tag[i]) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' ||
isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length == 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function generate(tree, text, options) {
var code = 'var c = [cx];var b = "";var _ = this;' +
walk(tree) + 'return b;';
if (options.asString) {
return 'function(cx,p){' + code + ';};';
}
var template = new HoganTemplate(text);
template.r = new Function('cx', 'p', code);
return template;
}
var rQuot = /\"/g, rNewline = /\n/g, rCr = /\r/g, rSlash = /\\/g;
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r')
};
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i].n);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('\n');
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text(tree[i]);
}
}
return code;
}
function section(nodes, id, method, start, end) {
var code = 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),';
code += 'c,p,0,' + start + ',' + end + ')){';
code += 'b += _.rs(c,p,';
code += 'function(c,p){ var b = "";';
code += walk(nodes);
code += 'return b;});c.pop();}';
code += 'else{b += _.b; _.b = ""};';
return code;
}
function invertedSection(nodes, id, method) {
var code = 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0)){';
code += walk(nodes);
code += '};';
return code;
}
function partial(id) {
return 'b += _.rp("' + esc(id) + '",c[c.length - 1],p);';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += "' + esc(id) + '";';
}
return ({
scan: scan,
parse: function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
cache: {},
compile: function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
options = options || {};
var t = this.cache[text];
if (t) {
return t;
}
t = generate(this.parse(scan(text), options), text, options);
return this.cache[text] = t;
}
});
})();
// Export the hogan constructor for Node.js and CommonJS.
if (typeof module !== 'undefined' && module.exports) {
module.exports = Hogan;
module.exports.Template = HoganTemplate;
} else if (typeof exports !== 'undefined') {
exports.Hogan = Hogan;
exports.HoganTemplate = HoganTemplate;
}

File diff suppressed because one or more lines are too long

View File

@ -1,545 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var HoganTemplate = (function () {
function constructor(text) {
this.text = text;
}
constructor.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
return partial.r(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (!inverted && typeof val == 'function') {
val = this.ls(val, ctx, partials, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var t = val.call(cx, text, function(t) {
return Hogan.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = Hogan.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = val.call(cx);
if (val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
if (typeof t == 'function') {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
return Hogan.compile(val.call(cx).toString()).render(cx, partials);
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String(str === null ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
return constructor;
})();
var Hogan = (function () {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
i++;
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function generate(tree, text, options) {
var code = 'i = i || "";var c = [cx];var b = i + "";var _ = this;'
+ walk(tree)
+ 'return b;';
if (options.asString) {
return 'function(cx,p,i){' + code + ';}';
}
var template = new HoganTemplate(text);
template.r = new Function('cx', 'p', 'i', code);
return template;
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c[c.length - 1],p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
return ({
scan: scan,
parse: function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
cache: {},
compile: function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var t = this.cache[text];
if (t) {
return t;
}
t = generate(this.parse(scan(text, options.delimiters), options), text, options);
return this.cache[text] = t;
}
});
})();
// Export the hogan constructor for Node.js and CommonJS.
if (typeof module !== 'undefined' && module.exports) {
module.exports = Hogan;
module.exports.Template = HoganTemplate;
} else if (typeof define === 'function' && define.amd) {
define(function () { return Hogan; });
} else if (typeof exports !== 'undefined') {
exports.Hogan = Hogan;
exports.HoganTemplate = HoganTemplate;
}

File diff suppressed because one or more lines are too long

View File

@ -1,576 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);
(function (Hogan) {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
Hogan.scan = function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
if (ctag == '}}') {
i++;
} else {
cleanTripleStache(tokens[tokens.length - 1]);
}
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function cleanTripleStache(token) {
if (token.n.substr(token.n.length - 1) === '}') {
token.n = token.n.substring(0, token.n.length - 1);
}
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function writeCode(tree) {
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
}
Hogan.generate = function (code, text, options) {
if (options.asString) {
return 'function(c,p,i){' + code + ';}';
}
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
Hogan.parse = function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
Hogan.cache = {};
Hogan.compile = function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var key = text + '||' + !!options.asString;
var t = this.cache[key];
if (t) {
return t;
}
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
return this.cache[key] = t;
};
})(typeof exports !== 'undefined' ? exports : Hogan);
if (typeof define === 'function' && define.amd) {
define(Hogan);
}

View File

@ -1,576 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);
(function (Hogan) {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
Hogan.scan = function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
if (ctag == '}}') {
i++;
} else {
cleanTripleStache(tokens[tokens.length - 1]);
}
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function cleanTripleStache(token) {
if (token.n.substr(token.n.length - 1) === '}') {
token.n = token.n.substring(0, token.n.length - 1);
}
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function writeCode(tree) {
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
}
Hogan.generate = function (code, text, options) {
if (options.asString) {
return 'function(c,p,i){' + code + ';}';
}
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
Hogan.parse = function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
Hogan.cache = {};
Hogan.compile = function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var key = text + '||' + !!options.asString;
var t = this.cache[key];
if (t) {
return t;
}
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
return this.cache[key] = t;
};
})(typeof exports !== 'undefined' ? exports : Hogan);
if (typeof module !== 'undefined' && module.exports) {
module.exports = Hogan;
}

View File

@ -1,572 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);
(function (Hogan) {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
Hogan.scan = function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
if (ctag == '}}') {
i++;
} else {
cleanTripleStache(tokens[tokens.length - 1]);
}
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function cleanTripleStache(token) {
if (token.n.substr(token.n.length - 1) === '}') {
token.n = token.n.substring(0, token.n.length - 1);
}
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function writeCode(tree) {
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
}
Hogan.generate = function (code, text, options) {
if (options.asString) {
return 'function(c,p,i){' + code + ';}';
}
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
Hogan.parse = function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
Hogan.cache = {};
Hogan.compile = function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var key = text + '||' + !!options.asString;
var t = this.cache[key];
if (t) {
return t;
}
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
return this.cache[key] = t;
};
})(typeof exports !== 'undefined' ? exports : Hogan);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,619 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// A wrapper for compatibility with Mustache.js, quirks and all
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);
(function (Hogan) {
// Setup regex assignments
// remove whitespace according to Mustache spec
var rIsWhitespace = /\S/,
rQuot = /\"/g,
rNewline = /\n/g,
rCr = /\r/g,
rSlash = /\\/g,
tagTypes = {
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
};
Hogan.scan = function scan(text, delimiters) {
var len = text.length,
IN_TEXT = 0,
IN_TAG_TYPE = 1,
IN_TAG = 2,
state = IN_TEXT,
tagType = null,
tag = null,
buf = '',
tokens = [],
seenTag = false,
i = 0,
lineStart = 0,
otag = '{{',
ctag = '}}';
function addBuf() {
if (buf.length > 0) {
tokens.push(new String(buf));
buf = '';
}
}
function lineIsWhitespace() {
var isAllWhitespace = true;
for (var j = lineStart; j < tokens.length; j++) {
isAllWhitespace =
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
if (!isAllWhitespace) {
return false;
}
}
return isAllWhitespace;
}
function filterLine(haveSeenTag, noNewLine) {
addBuf();
if (haveSeenTag && lineIsWhitespace()) {
for (var j = lineStart, next; j < tokens.length; j++) {
if (!tokens[j].tag) {
if ((next = tokens[j+1]) && next.tag == '>') {
// set indent to token value
next.indent = tokens[j].toString()
}
tokens.splice(j, 1);
}
}
} else if (!noNewLine) {
tokens.push({tag:'\n'});
}
seenTag = false;
lineStart = tokens.length;
}
function changeDelimiters(text, index) {
var close = '=' + ctag,
closeIndex = text.indexOf(close, index),
delimiters = trim(
text.substring(text.indexOf('=', index) + 1, closeIndex)
).split(' ');
otag = delimiters[0];
ctag = delimiters[1];
return closeIndex + close.length - 1;
}
if (delimiters) {
delimiters = delimiters.split(' ');
otag = delimiters[0];
ctag = delimiters[1];
}
for (i = 0; i < len; i++) {
if (state == IN_TEXT) {
if (tagChange(otag, text, i)) {
--i;
addBuf();
state = IN_TAG_TYPE;
} else {
if (text.charAt(i) == '\n') {
filterLine(seenTag);
} else {
buf += text.charAt(i);
}
}
} else if (state == IN_TAG_TYPE) {
i += otag.length - 1;
tag = tagTypes[text.charAt(i + 1)];
tagType = tag ? text.charAt(i + 1) : '_v';
if (tagType == '=') {
i = changeDelimiters(text, i);
state = IN_TEXT;
} else {
if (tag) {
i++;
}
state = IN_TAG;
}
seenTag = i;
} else {
if (tagChange(ctag, text, i)) {
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
buf = '';
i += ctag.length - 1;
state = IN_TEXT;
if (tagType == '{') {
if (ctag == '}}') {
i++;
} else {
cleanTripleStache(tokens[tokens.length - 1]);
}
}
} else {
buf += text.charAt(i);
}
}
}
filterLine(seenTag, true);
return tokens;
}
function cleanTripleStache(token) {
if (token.n.substr(token.n.length - 1) === '}') {
token.n = token.n.substring(0, token.n.length - 1);
}
}
function trim(s) {
if (s.trim) {
return s.trim();
}
return s.replace(/^\s*|\s*$/g, '');
}
function tagChange(tag, text, index) {
if (text.charAt(index) != tag.charAt(0)) {
return false;
}
for (var i = 1, l = tag.length; i < l; i++) {
if (text.charAt(index + i) != tag.charAt(i)) {
return false;
}
}
return true;
}
function buildTree(tokens, kind, stack, customTags) {
var instructions = [],
opener = null,
token = null;
while (tokens.length > 0) {
token = tokens.shift();
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
stack.push(token);
token.nodes = buildTree(tokens, token.tag, stack, customTags);
instructions.push(token);
} else if (token.tag == '/') {
if (stack.length === 0) {
throw new Error('Closing tag without opener: /' + token.n);
}
opener = stack.pop();
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
}
opener.end = token.i;
return instructions;
} else {
instructions.push(token);
}
}
if (stack.length > 0) {
throw new Error('missing closing tag: ' + stack.pop().n);
}
return instructions;
}
function isOpener(token, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].o == token.n) {
token.tag = '#';
return true;
}
}
}
function isCloser(close, open, tags) {
for (var i = 0, l = tags.length; i < l; i++) {
if (tags[i].c == close && tags[i].o == open) {
return true;
}
}
}
function writeCode(tree) {
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
}
Hogan.generate = function (code, text, options) {
if (options.asString) {
return 'function(c,p,i){' + code + ';}';
}
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
}
function esc(s) {
return s.replace(rSlash, '\\\\')
.replace(rQuot, '\\\"')
.replace(rNewline, '\\n')
.replace(rCr, '\\r');
}
function chooseMethod(s) {
return (~s.indexOf('.')) ? 'd' : 'f';
}
function walk(tree) {
var code = '';
for (var i = 0, l = tree.length; i < l; i++) {
var tag = tree[i].tag;
if (tag == '#') {
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
} else if (tag == '^') {
code += invertedSection(tree[i].nodes, tree[i].n,
chooseMethod(tree[i].n));
} else if (tag == '<' || tag == '>') {
code += partial(tree[i]);
} else if (tag == '{' || tag == '&') {
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
} else if (tag == '\n') {
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
} else if (tag == '_v') {
code += variable(tree[i].n, chooseMethod(tree[i].n));
} else if (tag === undefined) {
code += text('"' + esc(tree[i]) + '"');
}
}
return code;
}
function section(nodes, id, method, start, end, tags) {
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
'b += _.rs(c,p,' +
'function(c,p){ var b = "";' +
walk(nodes) +
'return b;});c.pop();}' +
'else{b += _.b; _.b = ""};';
}
function invertedSection(nodes, id, method) {
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
walk(nodes) +
'};';
}
function partial(tok) {
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
}
function tripleStache(id, method) {
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
}
function variable(id, method) {
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
}
function text(id) {
return 'b += ' + id + ';';
}
Hogan.parse = function(tokens, options) {
options = options || {};
return buildTree(tokens, '', [], options.sectionTags || []);
},
Hogan.cache = {};
Hogan.compile = function(text, options) {
// options
//
// asString: false (default)
//
// sectionTags: [{o: '_foo', c: 'foo'}]
// An array of object with o and c fields that indicate names for custom
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
//
// delimiters: A string that overrides the default delimiters.
// Example: "<% %>"
//
options = options || {};
var key = text + '||' + !!options.asString;
var t = this.cache[key];
if (t) {
return t;
}
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
return this.cache[key] = t;
};
})(typeof exports !== 'undefined' ? exports : Hogan);
var Mustache = (function (Hogan) {
// Mustache.js has non-spec partial context behavior
function mustachePartial(name, context, partials, indent) {
var partialScope = this.f(name, context, partials, 0);
var cx = context;
if (partialScope) {
cx = cx.concat(partialScope);
}
return Hogan.Template.prototype.rp.call(this, name, cx, partials, indent);
}
var HoganTemplateWrapper = function(renderFunc, text, compiler){
this.rp = mustachePartial;
Hogan.Template.call(this, renderFunc, text, compiler);
};
HoganTemplateWrapper.prototype = Hogan.Template.prototype;
// Add a wrapper for Hogan's generate method. Mustache and Hogan keep
// separate caches, and Mustache returns wrapped templates.
var wrapper;
var HoganWrapper = function(){
this.cache = {};
this.generate = function(code, text, options) {
return new HoganTemplateWrapper(new Function('c', 'p', 'i', code), text, wrapper);
}
};
HoganWrapper.prototype = Hogan;
wrapper = new HoganWrapper();
return {
to_html: function(text, data, partials, sendFun) {
var template = wrapper.compile(text);
var result = template.render(data, partials);
if (!sendFun) {
return result;
}
sendFun(result);
}
}
})(Hogan);

View File

@ -1,233 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hogan = {};
(function (Hogan) {
Hogan.Template = function constructor(renderFunc, text, compiler) {
if (renderFunc) {
this.r = renderFunc;
}
this.c = compiler;
this.text = text || '';
}
Hogan.Template.prototype = {
// render: replaced by generated code.
r: function (context, partials, indent) { return ''; },
// variable escaping
v: hoganEscape,
render: function render(context, partials, indent) {
return this.ri([context], partials || {}, indent);
},
// render internal -- a hook for overrides that catches partials too
ri: function (context, partials, indent) {
return this.r(context, partials, indent);
},
// tries to find a partial in the curent scope and render it
rp: function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial);
}
return partial.ri(context, partials, indent);
},
// render a section
rs: function(context, partials, section) {
var buf = '',
tail = context[context.length - 1];
if (!isArray(tail)) {
return buf = section(context, partials);
}
for (var i = 0; i < tail.length; i++) {
context.push(tail[i]);
buf += section(context, partials);
context.pop();
}
return buf;
},
// maybe start a section
s: function(val, ctx, partials, inverted, start, end, tags) {
var pass;
if (isArray(val) && val.length === 0) {
return false;
}
if (typeof val == 'function') {
val = this.ls(val, ctx, partials, inverted, start, end, tags);
}
pass = (val === '') || !!val;
if (!inverted && pass && ctx) {
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
}
return pass;
},
// find values with dotted names
d: function(key, ctx, partials, returnFound) {
var names = key.split('.'),
val = this.f(names[0], ctx, partials, returnFound),
cx = null;
if (key === '.' && isArray(ctx[ctx.length - 2])) {
return ctx[ctx.length - 1];
}
for (var i = 1; i < names.length; i++) {
if (val && typeof val == 'object' && names[i] in val) {
cx = val;
val = val[names[i]];
} else {
val = '';
}
}
if (returnFound && !val) {
return false;
}
if (!returnFound && typeof val == 'function') {
ctx.push(cx);
val = this.lv(val, ctx, partials);
ctx.pop();
}
return val;
},
// find values with normal names
f: function(key, ctx, partials, returnFound) {
var val = false,
v = null,
found = false;
for (var i = ctx.length - 1; i >= 0; i--) {
v = ctx[i];
if (v && typeof v == 'object' && key in v) {
val = v[key];
found = true;
break;
}
}
if (!found) {
return (returnFound) ? false : "";
}
if (!returnFound && typeof val == 'function') {
val = this.lv(val, ctx, partials);
}
return val;
},
// higher order templates
ho: function(val, cx, partials, text, tags) {
var compiler = this.c;
var t = val.call(cx, text, function(t) {
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
});
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
this.b = s;
return false;
},
// higher order template result buffer
b: '',
// lambda replace section
ls: function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
if (inverted) {
return true;
} else if (this.c) {
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
}
}
return t;
},
// lambda replace variable
lv: function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = result.toString();
if (this.c && ~result.indexOf("{{")) {
return this.c.compile(result).render(cx, partials);
}
return result;
}
};
var rAmp = /&/g,
rLt = /</g,
rGt = />/g,
rApos =/\'/g,
rQuot = /\"/g,
hChars =/[&<>\"\']/;
function hoganEscape(str) {
str = String((str === null || str === undefined) ? '' : str);
return hChars.test(str) ?
str
.replace(rAmp,'&amp;')
.replace(rLt,'&lt;')
.replace(rGt,'&gt;')
.replace(rApos,'&#39;')
.replace(rQuot, '&quot;') :
str;
}
var isArray = Array.isArray || function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
};
})(typeof exports !== 'undefined' ? exports : Hogan);

View File

@ -1,5 +0,0 @@
/**
* @preserve Copyright 2012 Twitter, Inc.
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
*/
var Hogan={};(function(a){function h(a){return a=String(a===null||a===undefined?"":a),g.test(a)?a.replace(b,"&amp;").replace(c,"&lt;").replace(d,"&gt;").replace(e,"&#39;").replace(f,"&quot;"):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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 B

View File

@ -1,139 +0,0 @@
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>Hogan.js</title>
<meta name="description" content="">
<meta name="author" content="">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<!-- CSS
================================================== -->
<link rel="stylesheet" href="stylesheets/skeleton.css">
<link rel="stylesheet" href="stylesheets/layout.css">
</head>
<body>
<!-- Primary Page Layout
================================================== -->
<header class="hogan-hero">
<div class="stripes"></div>
<div class="noise"></div>
<div class="container">
<h1>Hogan.js</h1>
<h3>JavaScript templating from Twitter.</h3>
<a href="https://github.com/twitter/hogan.js" class="download button">View on Github</a>
</div>
</header>
<div class="primary container">
<!-- Layout 1 -->
<div class="five columns">
<h4>Getting started</h4>
<p>
Hogan.js is a 2.5k JS templating engine developed at Twitter. Use it as a part of your asset packager to compile templates ahead of time or include it in your browser to handle dynamic templates.
</p>
<p>
If you're developing with Node.js, just use NPM to add the Hogan package.
</p>
<pre><code>$ npm install hogan.js</code></pre>
<p>
Alternatively, drop hogan.js in your browser by adding the following script.
</p>
<pre><code>&lt;script src="http://twitter.github.com/hogan.js/builds/{{version}}/hogan.js"&gt;&lt;/script&gt;</code></pre>
</div>
<div class="ten columns offset-by-one">
<script src="https://gist.github.com/1484613.js"> </script>
</div>
<div class="hogan-divider">
<div class="hogan-icon"></div>
</div>
<!-- Layout 2 -->
<div class="five columns">
<h4>Templates</h4>
<p>
Hogan.js was developed against the mustache test suite, so everything that holds true for templates as specified <a href="//mustache.github.com/mustache.5.html">here</a>, is also the case for hogan.js.
</p>
<p>
That means you get variables, sections, lambdas, partials, filters, and everything else you've come to expect from mustache templating - only much, much faster.
</p>
</div>
<div class="ten columns offset-by-one">
<script src="https://gist.github.com/1484342.js"></script>
</div>
<div class="hogan-divider">
<div class="hogan-icon"></div>
</div>
<!-- Layout 3 -->
<div class="five columns">
<h4>Compiling</h4>
<p>
Use <code>hogan.compile()</code> to precompile your templates into vanilla JS.
</p>
<p>
It's best to serve your templates precompiled whenever you can (rather than the raw templates), as parsing is the most time consuming operation.
</p>
<p>
</p>
</div>
<div class="ten columns offset-by-one">
<script src="https://gist.github.com/1484513.js"> </script>
</div>
<div class="hogan-divider">
<div class="hogan-icon"></div>
</div>
<!-- Layout 4 -->
<div class="five columns">
<h4 id='rendering'>Rendering</h4>
<p>
Once compiled, call the <code>render()</code> method with a context and optional partials object.
</p>
<p>
If supplying partials, you can compile them ahead of time, or pass string templates.</p>
<p>
</p>
</div>
<div class="ten columns offset-by-one">
<script src="https://gist.github.com/1575714.js"> </script>
</div>
<div class="sixteen columns hogan-footer">
<span class="copyright">
Designed and built with all the love in the world <a href="http://twitter.com/twitter" target="_blank">@twitter</a> by <a href="http://twitter.com/sayrer" target="_blank">@sayrer</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.<br />
Code licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>. Documentation licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.
</span>
<span class="colophon">
<a href="#">Back to top</a>
</span>
</div>
</div><!-- container -->
<!-- End Document
================================================== -->
</body>
</html>

View File

@ -1,206 +0,0 @@
/* #Reset & Basics (Inspired by E. Meyers)
================================================== */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block; }
body {
line-height: 1; }
ol, ul {
list-style: none; }
blockquote, q {
quotes: none; }
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none; }
table {
border-collapse: collapse;
border-spacing: 0; }
/* #Basic Styles
================================================== */
body {
background: #fff;
font: 14px/24px "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #000;
-webkit-font-smoothing: antialiased; /* Fix for webkit rendering */
-webkit-text-size-adjust: 100%;
}
a {
color: #999113;
text-decoration: none;
}
a:hover {
color: #7b750e;
text-decoration: underline;
}
/* #Typography
================================================== */
h1, h2, h3, h4, h5, h6 {
font-weight: bold; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; }
h1 { font-size: 75px; line-height: 80px; margin-bottom: 14px;}
h2 { font-size: 35px; line-height: 40px; margin-bottom: 10px; }
h3 { font-size: 28px; line-height: 34px; margin-bottom: 8px; }
h4 { font-size: 21px; line-height: 30px; margin-bottom: 4px; }
h5 { font-size: 17px; line-height: 24px; }
h6 { font-size: 14px; line-height: 21px; }
p { margin-bottom: 22px; }
/* #Main styles
================================================== */
/* Hogan Hero */
.hogan-hero {
position: relative;
background: #333; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover, #333 0%, #000 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#333), color-stop(100%,#000)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, #333 0%,#000 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover, #333 0%,#000 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover, #333 0%,#000 100%); /* IE10+ */
background: radial-gradient(center, ellipse cover, #333 0%,#000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#333', endColorstr='#000',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
}
.hogan-hero .container {
padding: 180px 0;
}
.hogan-hero h1 {
letter-spacing: -3px;
color: #fff;
position: relative;
margin-bottom: 5px;
}
.hogan-hero h3 {
max-width: 650px;
margin-bottom: 20px;
color: #fff;
}
.hogan-hero .noise,
.hogan-hero .stripes {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.hogan-hero .noise {
background: url(../images/noise.png) repeat;
}
.hogan-hero .stripes {
background: url(../images/stripes.png) repeat;
}
/* Primary content container */
.primary.container {
padding-top: 100px;
}
/*Hogan divider */
.hogan-divider {
padding-top: 60px;
border-bottom: 1px solid #ddd;
margin-bottom: 60px;
clear: both;
position: relative;
}
.hogan-icon {
width: 40px;
height: 30px;
position: absolute;
left: 50%;
top: 46px;
margin-left: -20px;
background: url('../images/small-hogan-icon.png') white no-repeat center center;
}
/* Button style */
.button {
display: inline-block;
cursor: pointer;
background: #dfd52e;
border-radius: 3px;
margin-bottom: 20px;
color: #000;
text-transform: uppercase;
text-decoration: none;
font-size: 15px;
padding: 0 34px;
line-height: 46px;
font-weight: bold;
-webkit-transition: background-color .3s ease-in-out;
-moz-transition: background-color .3s ease-in-out;
transition: background-color .3s ease-in-out;
}
.button:hover {
text-decoration: inherit;
color: inherit;
background-color: #f5e810;
}
/* Hogan footer */
.hogan-footer {
border-top: 1px solid #ddd;
margin-top: 60px;
padding: 20px 0 40px;
color: #999;
font-size: 12px;
}
.hogan-footer .copyright {
float: left;
}
.hogan-footer .colophon {
float: right;
}
pre, code {
background: #F8F8FF;
border: 1px solid #DDD;
padding: 5px 10px;
margin-bottom: 20px;
font-family: courier;
overflow: hidden;
}
pre code {
border: 0;
padding: 0;
margin-bottom: 0;
}
/* #Media Queries
================================================== */
/* Smaller than standard 960 (devices and browsers) */
@media only screen and (max-width: 959px) {}
/* Tablet Portrait size to standard 960 (devices and browsers) */
@media only screen and (min-width: 768px) and (max-width: 959px) {}
/* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {
.hogan-hero .container {
padding: 100px 0;
}
}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {}
/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {}

View File

@ -1,236 +0,0 @@
/*
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/
/* Table of Contents
==================================================
#Base 960 Grid
#Tablet (Portrait)
#Mobile (Portrait)
#Mobile (Landscape)
#Clearing */
/* #Base 960 Grid
================================================== */
.container { position: relative; width: 960px; margin: 0 auto; padding: 0; }
.column, .columns { float: left; display: inline; margin-left: 10px; margin-right: 10px; }
.row { margin-bottom: 20px; }
/* Nested Column Classes */
.column.alpha, .columns.alpha { margin-left: 0; }
.column.omega, .columns.omega { margin-right: 0; }
/* Base Grid */
.container .one.column { width: 40px; }
.container .two.columns { width: 100px; }
.container .three.columns { width: 160px; }
.container .four.columns { width: 220px; }
.container .five.columns { width: 280px; }
.container .six.columns { width: 340px; }
.container .seven.columns { width: 400px; }
.container .eight.columns { width: 460px; }
.container .nine.columns { width: 520px; }
.container .ten.columns { width: 580px; }
.container .eleven.columns { width: 640px; }
.container .twelve.columns { width: 700px; }
.container .thirteen.columns { width: 760px; }
.container .fourteen.columns { width: 820px; }
.container .fifteen.columns { width: 880px; }
.container .sixteen.columns { width: 940px; }
.container .one-third.column { width: 300px; }
.container .two-thirds.column { width: 620px; }
/* Offsets */
.container .offset-by-one { padding-left: 60px; }
.container .offset-by-two { padding-left: 120px; }
.container .offset-by-three { padding-left: 180px; }
.container .offset-by-four { padding-left: 240px; }
.container .offset-by-five { padding-left: 300px; }
.container .offset-by-six { padding-left: 360px; }
.container .offset-by-seven { padding-left: 420px; }
.container .offset-by-eight { padding-left: 480px; }
.container .offset-by-nine { padding-left: 540px; }
.container .offset-by-ten { padding-left: 600px; }
.container .offset-by-eleven { padding-left: 660px; }
.container .offset-by-twelve { padding-left: 720px; }
.container .offset-by-thirteen { padding-left: 780px; }
.container .offset-by-fourteen { padding-left: 840px; }
.container .offset-by-fifteen { padding-left: 900px; }
/* #Tablet (Portrait)
================================================== */
/* Note: Design for a width of 768px */
@media only screen and (min-width: 768px) and (max-width: 959px) {
.container { width: 768px; }
.container .column,
.container .columns { margin-left: 10px; margin-right: 10px; }
.column.alpha, .columns.alpha { margin-left: 0; margin-right: 10px; }
.column.omega, .columns.omega { margin-right: 0; margin-left: 10px; }
.container .one.column { width: 28px; }
.container .two.columns { width: 76px; }
.container .three.columns { width: 124px; }
.container .four.columns { width: 172px; }
.container .five.columns { width: 220px; }
.container .six.columns { width: 268px; }
.container .seven.columns { width: 316px; }
.container .eight.columns { width: 364px; }
.container .nine.columns { width: 412px; }
.container .ten.columns { width: 460px; }
.container .eleven.columns { width: 508px; }
.container .twelve.columns { width: 556px; }
.container .thirteen.columns { width: 604px; }
.container .fourteen.columns { width: 652px; }
.container .fifteen.columns { width: 700px; }
.container .sixteen.columns { width: 748px; }
.container .one-third.column { width: 236px; }
.container .two-thirds.column { width: 492px; }
/* Offsets */
.container .offset-by-one { padding-left: 48px; }
.container .offset-by-two { padding-left: 96px; }
.container .offset-by-three { padding-left: 144px; }
.container .offset-by-four { padding-left: 192px; }
.container .offset-by-five { padding-left: 240px; }
.container .offset-by-six { padding-left: 288px; }
.container .offset-by-seven { padding-left: 336px; }
.container .offset-by-eight { padding-left: 348px; }
.container .offset-by-nine { padding-left: 432px; }
.container .offset-by-ten { padding-left: 480px; }
.container .offset-by-eleven { padding-left: 528px; }
.container .offset-by-twelve { padding-left: 576px; }
.container .offset-by-thirteen { padding-left: 624px; }
.container .offset-by-fourteen { padding-left: 672px; }
.container .offset-by-fifteen { padding-left: 720px; }
}
/* #Mobile (Portrait)
================================================== */
/* Note: Design for a width of 320px */
@media only screen and (max-width: 767px) {
.container { width: 300px; }
.columns, .column { margin: 0; }
.container .one.column,
.container .two.columns,
.container .three.columns,
.container .four.columns,
.container .five.columns,
.container .six.columns,
.container .seven.columns,
.container .eight.columns,
.container .nine.columns,
.container .ten.columns,
.container .eleven.columns,
.container .twelve.columns,
.container .thirteen.columns,
.container .fourteen.columns,
.container .fifteen.columns,
.container .sixteen.columns,
.container .one-third.column,
.container .two-thirds.column { width: 300px; }
/* Offsets */
.container .offset-by-one,
.container .offset-by-two,
.container .offset-by-three,
.container .offset-by-four,
.container .offset-by-five,
.container .offset-by-six,
.container .offset-by-seven,
.container .offset-by-eight,
.container .offset-by-nine,
.container .offset-by-ten,
.container .offset-by-eleven,
.container .offset-by-twelve,
.container .offset-by-thirteen,
.container .offset-by-fourteen,
.container .offset-by-fifteen { padding-left: 0; }
}
/* #Mobile (Landscape)
================================================== */
/* Note: Design for a width of 480px */
@media only screen and (min-width: 480px) and (max-width: 767px) {
.container { width: 420px; }
.columns, .column { margin: 0; }
.container .one.column,
.container .two.columns,
.container .three.columns,
.container .four.columns,
.container .five.columns,
.container .six.columns,
.container .seven.columns,
.container .eight.columns,
.container .nine.columns,
.container .ten.columns,
.container .eleven.columns,
.container .twelve.columns,
.container .thirteen.columns,
.container .fourteen.columns,
.container .fifteen.columns,
.container .sixteen.columns,
.container .one-third.column,
.container .two-thirds.column { width: 420px; }
}
/* #Clearing
================================================== */
/* Self Clearing Goodness */
.container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; }
/* Use clearfix class on parent to clear nested columns,
or wrap each row of columns in a <div class="row"> */
.clearfix:before,
.clearfix:after,
.row:before,
.row:after {
content: '\0020';
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0; }
.row:after,
.clearfix:after {
clear: both; }
.row,
.clearfix {
zoom: 1; }
/* You can also use a <br class="clear" /> to clear columns */
.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}

View File

@ -1,21 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{{{template}}}
{{{compiler}}}
if (typeof define === 'function' && define.amd) {
define(Hogan);
}

View File

@ -1,21 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{{{template}}}
{{{compiler}}}
if (typeof module !== 'undefined' && module.exports) {
module.exports = Hogan;
}

View File

@ -1,17 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{{{template}}}
{{{compiler}}}

View File

@ -1,64 +0,0 @@
/*
* Copyright 2011 Twitter, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// A wrapper for compatibility with Mustache.js, quirks and all
{{{template}}}
{{{compiler}}}
var Mustache = (function (Hogan) {
// Mustache.js has non-spec partial context behavior
function mustachePartial(name, context, partials, indent) {
var partialScope = this.f(name, context, partials, 0);
var cx = context;
if (partialScope) {
cx = cx.concat(partialScope);
}
return Hogan.Template.prototype.rp.call(this, name, cx, partials, indent);
}
var HoganTemplateWrapper = function(renderFunc, text, compiler){
this.rp = mustachePartial;
Hogan.Template.call(this, renderFunc, text, compiler);
};
HoganTemplateWrapper.prototype = Hogan.Template.prototype;
// Add a wrapper for Hogan's generate method. Mustache and Hogan keep
// separate caches, and Mustache returns wrapped templates.
var wrapper;
var HoganWrapper = function(){
this.cache = {};
this.generate = function(code, text, options) {
return new HoganTemplateWrapper(new Function('c', 'p', 'i', code), text, wrapper);
}
};
HoganWrapper.prototype = Hogan;
wrapper = new HoganWrapper();
return {
to_html: function(text, data, partials, sendFun) {
var template = wrapper.compile(text);
var result = template.render(data, partials);
if (!sendFun) {
return result;
}
sendFun(result);
}
}
})(Hogan);

View File

@ -1,6 +0,0 @@
{
"name": "bootstrap-doc-builder"
, "version": "0.0.1"
, "description": "build bootstrap docs"
, "dependencies": { "hogan.js": "1.0.5-dev" }
}

View File

@ -1,70 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Components · Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: default
title: Components
---
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="">
<a href="./index.html">Home</a>
</li>
<li class="">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="active">
<a href="./components.html">Components</a>
</li>
<li class="">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
<!-- Subhead
================================================== -->
@ -123,27 +61,27 @@
<li><a tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="dropdown"&gt;
&lt;!-- Link or button to toggle dropdown --&gt;
&lt;ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu"&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Action&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Another action&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Something else here&lt;/a&gt;&lt;/li&gt;
&lt;li class="divider"&gt;&lt;/li&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Separated link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div class="dropdown">
<!-- Link or button to toggle dropdown -->
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
<li><a tabindex="-1" href="#">Action</a></li>
<li><a tabindex="-1" href="#">Another action</a></li>
<li><a tabindex="-1" href="#">Something else here</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
{% endhighlight %}
<h3>Aligning the menus</h3>
<p>Add <code>.pull-right</code> to a <code>.dropdown-menu</code> to right align the dropdown menu.</p>
<pre class="prettyprint linenums">
&lt;ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dLabel"&gt;
{% highlight html linenos %}
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dLabel">
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h3>Disabled menu options</h3>
<p>Add <code>.disabled</code> to a <code>&lt;li&gt;</code> in the dropdown to disable the link.</p>
@ -155,14 +93,14 @@
<li><a tabindex="-1" href="#">Another link</a></li>
</ul>
</div>
</div>
<pre class="prettyprint linenums">
&lt;ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu"&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Regular link&lt;/a&gt;&lt;/li&gt;
&lt;li class="disabled"&gt;&lt;a tabindex="-1" href="#"&gt;Disabled link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a tabindex="-1" href="#"&gt;Another link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
<li><a tabindex="-1" href="#">Regular link</a></li>
<li class="disabled"><a tabindex="-1" href="#">Disabled link</a></li>
<li><a tabindex="-1" href="#">Another link</a></li>
</ul>
{% endhighlight %}
</section>
@ -180,46 +118,46 @@
<p>Wrap a series of buttons with <code>.btn</code> in <code>.btn-group</code>.</p>
<div class="bs-docs-example">
<div class="btn-group" style="margin: 9px 0 5px;">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
<button type="button" class="btn">Left</button>
<button type="button" class="btn">Middle</button>
<button type="button" class="btn">Right</button>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group"&gt;
&lt;button class="btn"&gt;Left&lt;/button&gt;
&lt;button class="btn"&gt;Middle&lt;/button&gt;
&lt;button class="btn"&gt;Right&lt;/button&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="btn-group">
<button type="button" class="btn">Left</button>
<button type="button" class="btn">Middle</button>
<button type="button" class="btn">Right</button>
</div>
{% endhighlight %}
<h3>Multiple button groups</h3>
<p>Combine sets of <code>&lt;div class="btn-group"&gt;</code> into a <code>&lt;div class="btn-toolbar"&gt;</code> for more complex components.</p>
<div class="bs-docs-example">
<div class="btn-toolbar" style="margin: 0;">
<div class="btn-group">
<button class="btn">1</button>
<button class="btn">2</button>
<button class="btn">3</button>
<button class="btn">4</button>
<button type="button" class="btn">1</button>
<button type="button" class="btn">2</button>
<button type="button" class="btn">3</button>
<button type="button" class="btn">4</button>
</div>
<div class="btn-group">
<button class="btn">5</button>
<button class="btn">6</button>
<button class="btn">7</button>
<button type="button" class="btn">5</button>
<button type="button" class="btn">6</button>
<button type="button" class="btn">7</button>
</div>
<div class="btn-group">
<button class="btn">8</button>
<button type="button" class="btn">8</button>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-toolbar"&gt;
&lt;div class="btn-group"&gt;
...
&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="btn-toolbar">
<div class="btn-group">...</div>
<div class="btn-group">...</div>
<div class="btn-group">...</div>
</div>
{% endhighlight %}
<h3>Vertical button groups</h3>
<p>Make a set of buttons appear vertically stacked rather than horizontally.</p>
@ -231,11 +169,11 @@
<button type="button" class="btn"><i class="glyphicon-align-justify"></i></button>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group btn-group-vertical"&gt;
{% highlight html linenos %}
<div class="btn-group btn-group-vertical">
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
<h3>Justified button groups</h3>
<p>Make a group of buttons stretch at the same size to span the entire width of its parent. <strong>This only works with <code>&lt;a&gt;</code> elements</strong> as the <code>&lt;button&gt;</code> doesn't pick up these styles.</p>
@ -246,11 +184,11 @@
<a href="#" class="btn">Middle</a>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group btn-group-justified"&gt;
{% highlight html linenos %}
<div class="btn-group btn-group-justified">
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
</section>
@ -378,36 +316,45 @@
</div><!-- /btn-group -->
</div><!-- /btn-toolbar -->
</div>
<pre class="prettyprint linenums">
&lt;-- Single button --&gt;
&lt;div class="btn-group"&gt;
&lt;button type="button" class="btn dropdown-toggle" data-toggle="dropdown"&gt;
Action
&lt;span class="caret"&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;ul class="dropdown-menu"&gt;
&lt;!-- dropdown menu links --&gt;
&lt;/ul&gt;
&lt;/div&gt;
{% highlight html linenos %}
<!-- Single button -->
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
&lt;-- Split button --&gt;
&lt;div class="btn-group"&gt;
&lt;button class="btn"&gt;Action&lt;/button&gt;
&lt;button class="btn dropdown-toggle" data-toggle="dropdown"&gt;
&lt;span class="caret"&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;ul class="dropdown-menu"&gt;
&lt;!-- dropdown menu links --&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
<!-- Split button -->
<div class="btn-group">
<button class="btn">Action</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
{% endhighlight %}
<h3>Works with all button sizes</h3>
<p>Button dropdowns work at any size: <code>.btn-large</code>, <code>.btn-small</code>, or <code>.btn-mini</code>.</p>
<div class="bs-docs-example">
<div class="btn-toolbar" style="margin: 0;">
<div class="btn-group">
<button class="btn btn-large dropdown-toggle" data-toggle="dropdown">Large button <span class="caret"></span></button>
<button class="btn btn-large dropdown-toggle" type="button" data-toggle="dropdown">
Large button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
@ -417,7 +364,9 @@
</ul>
</div><!-- /btn-group -->
<div class="btn-group">
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">Small button <span class="caret"></span></button>
<button class="btn btn-small dropdown-toggle" type="button" data-toggle="dropdown">
Small button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
@ -427,7 +376,9 @@
</ul>
</div><!-- /btn-group -->
<div class="btn-group">
<button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">Mini button <span class="caret"></span></button>
<button class="btn btn-mini dropdown-toggle" type="button" data-toggle="dropdown">
Mini button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
@ -437,7 +388,38 @@
</ul>
</div><!-- /btn-group -->
</div><!-- /btn-toolbar -->
</div>
</div><!-- /example -->
{% highlight html linenos %}
<!-- Large button group -->
<div class="btn-group">
<button class="btn btn-large dropdown-toggle" type="button" data-toggle="dropdown">
Large button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
<!-- Small button group -->
<div class="btn-group">
<button class="btn btn-small dropdown-toggle" type="button" data-toggle="dropdown">
Small button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
<!-- Mini button group -->
<div class="btn-group">
<button class="btn btn-mini dropdown-toggle" type="button" data-toggle="dropdown">
Mini button <span class="caret"></span>
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
{% endhighlight %}
<h3>Dropup buttons</h3>
<p>Trigger dropdown menus above elements by adding <code>.dropup</code> to the parent.</p>
@ -466,18 +448,18 @@
</ul>
</div><!-- /btn-group -->
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group dropup"&gt;
&lt;button class="btn"&gt;Dropup&lt;/button&gt;
&lt;button class="btn dropdown-toggle" data-toggle="dropdown"&gt;
&lt;span class="caret"&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;ul class="dropdown-menu"&gt;
&lt;!-- dropdown menu links --&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div class="btn-group dropup">
<button class="btn">Dropup</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
{% endhighlight %}
</section>
@ -501,15 +483,13 @@
<li><a href="#">Messages</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-tabs"&gt;
&lt;li class="active"&gt;
&lt;a href="#"&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="nav nav-tabs">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Messages</a></li>
</ul>
{% endhighlight %}
<h2>List</h2>
<p>Swap the tabs class for <code>.nav-list</code>.</p>
@ -520,15 +500,13 @@
<li><a href="#">Messages</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-list"&gt;
&lt;li class="active"&gt;
&lt;a href="#"&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="nav nav-list">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Messages</a></li>
</ul>
{% endhighlight %}
<h2>Pills</h2>
<p>Take that same HTML, but use <code>.nav-pills</code> instead:</p>
@ -539,15 +517,13 @@
<li><a href="#">Messages</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-pills"&gt;
&lt;li class="active"&gt;
&lt;a href="#"&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="nav nav-pills">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Messages</a></li>
</ul>
{% endhighlight %}
<p>Pills are also vertically stackable. Just add <code>.nav-stacked</code>.</p>
<div class="bs-docs-example">
<ul class="nav nav-pills nav-stacked" style="max-width: 300px;">
@ -556,11 +532,11 @@
<li><a href="#">Messages</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-pills nav-stacked"&gt;
{% highlight html linenos %}
<ul class="nav nav-pills nav-stacked">
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h2>Options</h2>
@ -579,15 +555,14 @@
<li><a href="#">Messages</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-tabs nav-justified"&gt;
{% highlight html linenos %}
<ul class="nav nav-tabs nav-justified">
...
&lt;/ul&gt;
&lt;ul class="nav nav-pills nav-justified"&gt;
</ul>
<ul class="nav nav-pills nav-justified">
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h3>Disabled state</h3>
<p>For any nav component (tabs, pills, or list), add <code>.disabled</code> for <strong>gray links and no hover effects</strong>. Links will remain clickable, however, unless you remove the <code>href</code> attribute. Alternatively, you could implement custom JavaScript to prevent those clicks.</p>
@ -598,13 +573,14 @@
<li class="disabled"><a href="#">Disabled link</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-pills"&gt;
{% highlight html linenos %}
<ul class="nav nav-tabs">
...
&lt;li class="disabled"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
<li class="disabled"><a href="#">Disabled link</a></li>
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h3>Component alignment</h3>
<p>To align nav links, use the <code>.pull-left</code> or <code>.pull-right</code> utility classes. Both classes will add a CSS float in the specified direction.</p>
@ -622,7 +598,9 @@
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Help</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown <b class="caret"></b></a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
@ -633,21 +611,20 @@
</li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-tabs"&gt;
&lt;li class="dropdown"&gt;
&lt;a class="dropdown-toggle"
data-toggle="dropdown"
href="#"&gt;
Dropdown
&lt;b class="caret"&gt;&lt;/b&gt;
&lt;/a&gt;
&lt;ul class="dropdown-menu"&gt;
&lt;!-- links --&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="nav nav-tabs">
...
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu">
...
</ul>
</li>
...
</ul>
{% endhighlight %}
<h3>Pills with dropdowns</h3>
<div class="bs-docs-example">
@ -655,7 +632,9 @@
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Help</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown <b class="caret"></b></a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
@ -665,22 +644,21 @@
</ul>
</li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-pills"&gt;
&lt;li class="dropdown"&gt;
&lt;a class="dropdown-toggle"
data-toggle="dropdown"
href="#"&gt;
Dropdown
&lt;b class="caret"&gt;&lt;/b&gt;
&lt;/a&gt;
&lt;ul class="dropdown-menu"&gt;
&lt;!-- links --&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<ul class="nav nav-pills">
...
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu">
...
</ul>
</li>
...
</ul>
{% endhighlight %}
</section>
@ -705,21 +683,17 @@
<li><a href="#">Link</a></li>
</ul>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar"&gt;
&lt;a class="brand" href="#"&gt;Title&lt;/a&gt;
&lt;ul class="nav"&gt;
&lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</pre>
<hr class="bs-docs-separator">
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar">
<a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
{% endhighlight %}
<h2>Navbar components</h2>
@ -729,10 +703,10 @@
<div class="navbar">
<a class="brand" href="#">Title</a>
</div>
</div>
<pre class="prettyprint linenums">
&lt;a class="brand" href="#"&gt;Project name&lt;/a&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<a class="brand" href="#">Title</a>
{% endhighlight %}
<h3>Nav links</h3>
<p>Nav items are simple to add via unordered lists.</p>
@ -744,16 +718,14 @@
<li><a href="#">Link</a></li>
</ul>
</div>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav"&gt;
&lt;li class="active"&gt;
&lt;a href="#">Home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
{% endhighlight %}
<p>You can easily add dividers to your nav links with an empty list item and a simple class. Just add the appropriate class to <code>&lt;li&gt;</code> elements between links. Dividers will be horizontal to start, but at resolutions above 768px they become vertical with the navigation.</p>
<div class="bs-docs-example">
<div class="navbar">
@ -768,14 +740,14 @@
</ul>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<ul class="nav">
...
&lt;li class="divider"&gt;&lt;/li&gt;
<li class="divider"></li>
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h3>Forms</h3>
<p>To properly style and position a form within the navbar, add the appropriate classes as shown below. For a default form, include <code>.navbar-form</code> and either <code>.pull-left</code> or <code>.pull-right</code> to properly align it.</p>
@ -786,41 +758,24 @@
<button type="submit" class="btn">Submit</button>
</form>
</div>
</div>
<pre class="prettyprint linenums">
&lt;form class="pull-left"&gt;
&lt;input type="text" style="width: 200px;"&gt;
&lt;button type="submit" class="btn"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<form class="navbar-form pull-left">
<input type="text" style="width: 200px;">
<button type="submit" class="btn">Submit</button>
</form>
{% endhighlight %}
<h3>Component alignment</h3>
<p>Align nav links, search form, or text, use the <code>.pull-left</code> or <code>.pull-right</code> utility classes. Both classes will add a CSS float in the specified direction.</p>
<h3>Using dropdowns</h3>
<p>Add dropdowns and dropups to the nav with a bit of markup and the <a href="./javascript.html#dropdowns">dropdowns JavaScript plugin</a>.</p>
<pre class="prettyprint linenums">
&lt;ul class="nav"&gt;
&lt;li class="dropdown"&gt;
&lt;a href="#" class="dropdown-toggle" data-toggle="dropdown">
Account
&lt;b class="caret"&gt;&lt;/b&gt;
&lt;/a&gt;
&lt;ul class="dropdown-menu"&gt;
...
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Visit the <a href="./javascript.html#dropdowns">JavaScript dropdowns documentation</a> for more markup and information on calling dropdowns.</p>
<h3>Text</h3>
<p>Wrap strings of text in an element with <code>.navbar-text</code>, usually on a <code>&lt;p&gt;</code> tag for proper leading and color.</p>
<hr class="bs-docs-separator">
<h2>Optional display variations</h2>
<p>Fix the navbar to the top or bottom of the viewport with an additional class on the outermost div, <code>.navbar</code>.</p>
@ -837,12 +792,12 @@
</ul>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar navbar-fixed-top"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar navbar-fixed-top">
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
<h3>Fixed to bottom</h3>
<p>Add <code>.navbar-fixed-bottom</code> instead.</p>
@ -857,12 +812,12 @@
</ul>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar navbar-fixed-bottom"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar navbar-fixed-bottom">
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
<h3>Static top navbar</h3>
<p>Create a full-width navbar that scrolls away with the page by adding <code>.navbar-static-top</code>. Unlike the <code>.navbar-fixed-top</code> class, you do not need to change any padding on the <code>body</code>.</p>
@ -877,15 +832,12 @@
</ul>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar navbar-static-top"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar navbar-static-top">
...
&lt;/div&gt;
</pre>
<hr class="bs-docs-separator">
</div>
{% endhighlight %}
<h2>Responsive navbar</h2>
@ -935,40 +887,36 @@
</li>
</ul>
</div><!-- /.nav-collapse -->
</div>
</div><!-- /.container -->
</div><!-- /.navbar -->
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar">
<div class="container">
</div><!-- /navbar -->
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar"&gt;
&lt;div class="container"&gt;
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
&lt;!-- .btn-navbar is used as the toggle for collapsed navbar content --&gt;
&lt;a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"&gt;
&lt;span class="icon-bar"&gt;&lt;/span&gt;
&lt;span class="icon-bar"&gt;&lt;/span&gt;
&lt;span class="icon-bar"&gt;&lt;/span&gt;
&lt;/a&gt;
<!-- Be sure to leave the brand out there if you want it shown -->
<a class="brand" href="#">Title</a>
&lt;!-- Be sure to leave the brand out there if you want it shown --&gt;
&lt;a class="brand" href="#"&gt;Project name&lt;/a&gt;
<!-- Place everything within .navbar-collapse to hide it until above 768px -->
<div class="nav-collapse collapse navbar-responsive-collapse">
...
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar -->
{% endhighlight %}
&lt;!-- Everything you want hidden at 940px or less, place within here --&gt;
&lt;div class="nav-collapse collapse"&gt;
&lt;!-- .nav, .navbar-search, .navbar-form, etc --&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<div class="alert alert-info">
<strong>Heads up!</strong> The responsive navbar requires the <a href="./javascript.html#collapse">collapse plugin</a> and <a href="./scaffolding.html#responsive">responsive Bootstrap CSS file</a>.
</div>
<hr class="bs-docs-separator">
<h2>Inverted variation</h2>
<p>Modify the look of the navbar by adding <code>.navbar-inverse</code>.</p>
<div class="bs-docs-example">
@ -1018,12 +966,12 @@
</div><!-- /.nav-collapse -->
</div>
</div><!-- /navbar -->
</div>
<pre class="prettyprint linenums">
&lt;div class="navbar navbar-inverse"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="navbar navbar-inverse">
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
</section>
@ -1051,13 +999,14 @@
<li class="active">Data</li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="breadcrumb"&gt;
&lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Library&lt;/a&gt;&lt;/li&gt;
&lt;li class="active"&gt;Data&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="breadcrumb">
<li><a href="#">Home</a></li>
<li><a href="#">Library</a></li>
<li class="active">Data</li>
</ul>
{% endhighlight %}
</section>
@ -1084,17 +1033,17 @@
<li><a href="#">&raquo;</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pagination"&gt;
&lt;li&gt;&lt;a href="#"&gt;Prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Next&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="pagination">
<li><a href="#">&laquo;</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">&raquo;</a></li>
</ul>
{% endhighlight %}
<h3>Disabled and active states</h3>
<p>Links are customizable for different circumstances. Use <code>.disabled</code> for unclickable links and <code>.active</code> to indicate the current page.</p>
@ -1109,21 +1058,22 @@
<li><a href="#">&raquo;</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pagination"&gt;
&lt;li class="disabled"&gt;&lt;a href="#"&gt;&amp;laquo;&lt;/a&gt;&lt;/li&gt;
&lt;li class="active"&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt;
{% highlight html linenos %}
<ul class="pagination">
<li class="disabled"><a href="#">&laquo;</a></li>
<li class="active"><a href="#">1</a></li>
...
&lt;/ul&gt;
</pre>
<p>You can optionally swap out active or disabled anchors for spans to remove click functionality while retaining intended styles.</p>
<pre class="prettyprint linenums">
&lt;ul class="pagination"&gt;
&lt;li class="disabled"&gt;&lt;span&gt;&amp;laquo;&lt;/span&gt;&lt;/li&gt;
&lt;li class="active"&gt;&lt;span&gt;1&lt;/span&gt;&lt;/li&gt;
</ul>
{% endhighlight %}
<p>You can optionally swap out active or disabled anchors for <code>&lt;span&gt;</code> to remove click functionality while retaining intended styles.</p>
{% highlight html linenos %}
<ul class="pagination">
<li class="disabled"><span>&laquo;</span></li>
<li class="active"><span>1</span></li>
...
&lt;/ul&gt;
</pre>
</ul>
{% endhighlight %}
<h3>Sizes</h3>
<p>Fancy larger or smaller pagination? Add <code>.pagination-large</code>, <code>.pagination-small</code>, or <code>.pagination-mini</code> for additional sizes.</p>
@ -1173,20 +1123,13 @@
</ul>
</div>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pagination pagination-large"&gt;
...
&lt;/ul&gt;
&lt;ul class="pagination"&gt;
...
&lt;/ul&gt;
&lt;ul class="pagination pagination-small"&gt;
...
&lt;/ul&gt;
&lt;ul class="pagination pagination-mini"&gt;
...
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="pagination pagination-large">...</ul>
<ul class="pagination pagination">...</ul>
<ul class="pagination pagination-small">...</ul>
<ul class="pagination pagination-mini">...</ul>
{% endhighlight %}
<h2 id="pagination-pager">Pager</h2>
<p>Quick previous and next links for simple pagination implementations with light markup and styles. It's great for simple sites like blogs or magazines.</p>
@ -1199,12 +1142,12 @@
<li><a href="#">Next</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pager"&gt;
&lt;li&gt;&lt;a href="#"&gt;Previous&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Next&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
{% endhighlight %}
<h3>Aligned links</h3>
<p>Alternatively, you can align each link to the sides:</p>
@ -1214,16 +1157,13 @@
<li class="next"><a href="#">Newer &rarr;</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pager"&gt;
&lt;li class="previous"&gt;
&lt;a href="#"&gt;&amp;larr; Older&lt;/a&gt;
&lt;/li&gt;
&lt;li class="next"&gt;
&lt;a href="#"&gt;Newer &amp;rarr;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="pager">
<li class="previous"><a href="#">&larr; Older</a></li>
<li class="next"><a href="#">Newer &rarr;</a></li>
</ul>
{% endhighlight %}
<h3>Optional disabled state</h3>
<p>Pager links also use the general <code>.disabled</code> utility class from the pagination.</p>
@ -1233,14 +1173,13 @@
<li class="next"><a href="#">Newer &rarr;</a></li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="pager"&gt;
&lt;li class="previous disabled"&gt;
&lt;a href="#"&gt;&amp;larr; Older&lt;/a&gt;
&lt;/li&gt;
...
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="pager">
<li class="previous disabled"><a href="#">&larr; Older</a></li>
<li class="next"><a href="#">Newer &rarr;</a></li>
</ul>
{% endhighlight %}
</section>
@ -1257,12 +1196,9 @@
<div class="bs-docs-example">
<a href="#">Inbox <span class="counter">42</span></a>
</div>
<pre class="prettyprint linenums">
&lt;a href="#"&gt;
Inbox
&lt;span class="counter"&gt;42&lt;/span&gt;
&lt;/a&gt;
</pre>
{% highlight html linenos %}
<a href="#">Inbox <span class="counter">42</span></a>
{% endhighlight %}
<h4>Self collapsing</h4>
<p>When there are no new or unread items, counters will simply collapse (via CSS's <code>:empty</code> selector) provided no content exists within.</p>
@ -1292,15 +1228,17 @@
</li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-list"&gt;
&lt;li class="active"&gt;
&lt;a href="#"&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;...&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
{% highlight html linenos %}
<ul class="nav nav-list">
<li class="active">
<a href="#">
<span class="counter pull-right">42</span>
Home
</a>
</li>
...
</ul>
{% endhighlight %}
</section>
@ -1322,17 +1260,13 @@
<p><a class="btn btn-primary btn-large">Learn more</a></p>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="jumbotron"&gt;
&lt;h1&gt;Heading&lt;/h1&gt;
&lt;p&gt;Tagline&lt;/p&gt;
&lt;p&gt;
&lt;a class="btn btn-primary btn-large"&gt;
Learn more
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>...</p>
<p><a class="btn btn-primary btn-large">Learn more</a></p>
</div>
{% endhighlight %}
<h2>Page header</h2>
<p>A simple shell for an <code>h1</code> to appropriately space out and segment sections of content on a page. It can utilize the <code>h1</code>'s default <code>small</code>, element as well most other components (with additional styles).</p>
@ -1341,11 +1275,11 @@
<h1>Example page header <small>Subtext for header</small></h1>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="page-header"&gt;
&lt;h1&gt;Example page header &lt;small&gt;Subtext for header&lt;/small&gt;&lt;/h1&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="page-header">
<h1>Example page header <small>Subtext for header</small></h1>
</div>
{% endhighlight %}
</section>
@ -1384,17 +1318,17 @@
</a>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="row"&gt;
&lt;div class="span3"&gt;
&lt;a href="#" class="thumbnail"&gt;
&lt;img src="holder.js/260x180" alt=""&gt;
&lt;/a&gt;
&lt;/div&gt;
</div><!-- /.bs-docs-example -->
{% highlight html linenos %}
<div class="row">
<div class="span3">
<a href="#" class="thumbnail">
<img data-src="holder.js/260x180" alt="">
</a>
</div>
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
<h3>Custom content thumbnails</h3>
<p>With a bit of extra markup, it's possible to add any kind of HTML content like headings, paragraphs, or buttons into thumbnails.</p>
@ -1431,19 +1365,23 @@
</div>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="row"&gt;
&lt;div class="span4"&gt;
&lt;div class="thumbnail"&gt;
&lt;img data-src="holder.js/300x200" alt=""&gt;
&lt;h3&gt;Thumbnail label&lt;/h3&gt;
&lt;p&gt;Thumbnail caption...&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</div><!-- /.bs-docs-example -->
{% highlight html linenos %}
<div class="row">
<div class="span3">
<div class="thumbnail">
<img data-src="holder.js/300x200" alt="">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>
</div>
</div>
</div>
...
&lt;/div&gt;
</pre>
</div>
{% endhighlight %}
</section>
@ -1466,12 +1404,12 @@
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="alert"&gt;
&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
&lt;strong&gt;Warning!&lt;/strong&gt; Best check yo self, you're not looking too good.
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong> Best check yo self, you're not looking too good.
</div>
{% endhighlight %}
<h3>Block alerts</h3>
<p>For longer messages, increase the padding on the top and bottom of the alert wrapper by adding <code>.alert-block</code>.</p>
@ -1482,13 +1420,13 @@
<p>Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="alert alert-block"&gt;
&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
&lt;h4&gt;Warning!&lt;/h4&gt;
Best check yo self, you're not...
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="alert alert-block">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4>Warning!</h4>
<p>...</p>
</div>
{% endhighlight %}
<h3>Contextual alternatives</h3>
<p>Add optional classes to change an alert's connotation.</p>
@ -1506,11 +1444,11 @@
<strong>Heads up!</strong> This alert needs your attention, but it's not super important.
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="alert alert-error"&gt;... &lt;/div&gt;
&lt;div class="alert alert-success"&gt;...&lt;/div&gt;
&lt;div class="alert alert-info"&gt;...&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="alert alert-error">...</div>
<div class="alert alert-success">...</div>
<div class="alert alert-info">...</div>
{% endhighlight %}
</section>
@ -1533,11 +1471,11 @@
<div class="progress-bar" style="width: 60%;"></div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="progress"&gt;
&lt;div class="progress-bar" style="width: 60%;"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="progress">
<div class="progress-bar" style="width: 60%;"></div>
</div>
{% endhighlight %}
<h3>Additional colors</h3>
<p>Progress bars use some of the same button and alert classes for consistent styles.</p>
@ -1555,20 +1493,20 @@
<div class="progress-bar progress-bar-danger" style="width: 80%"></div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="progress"&gt;
&lt;div class="progress-bar progress-bar-info" style="width: 20%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress"&gt;
&lt;div class="progress-bar progress-bar-success" style="width: 40%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress"&gt;
&lt;div class="progress-bar progress-bar-warning" style="width: 60%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress"&gt;
&lt;div class="progress-bar progress-bar-danger" style="width: 80%"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="progress">
<div class="progress-bar progress-bar-info" style="width: 20%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 40%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-warning" style="width: 60%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-danger" style="width: 80%"></div>
</div>
{% endhighlight %}
<h3>Striped</h3>
<p>Uses a gradient to create a striped effect. Not available in IE8.</p>
@ -1586,20 +1524,20 @@
<div class="progress-bar progress-bar-danger" style="width: 80%"></div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="progress progress-striped"&gt;
&lt;div class="progress-bar progress-bar-info" style="width: 20%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress progress-striped"&gt;
&lt;div class="progress-bar progress-bar-success" style="width: 40%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress progress-striped"&gt;
&lt;div class="progress-bar progress-bar-warning" style="width: 60%"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="progress progress-striped"&gt;
&lt;div class="progress-bar progress-bar-danger" style="width: 80%"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="progress progress-striped">
<div class="progress-bar progress-bar-info" style="width: 20%"></div>
</div>
<div class="progress progress-striped">
<div class="progress-bar progress-bar-success" style="width: 40%"></div>
</div>
<div class="progress progress-striped">
<div class="progress-bar progress-bar-warning" style="width: 60%"></div>
</div>
<div class="progress progress-striped">
<div class="progress-bar progress-bar-danger" style="width: 80%"></div>
</div>
{% endhighlight %}
<h3>Animated</h3>
<p>Add <code>.active</code> to <code>.progress-striped</code> to animate the stripes right to left. Not available in all versions of IE.</p>
@ -1608,11 +1546,11 @@
<div class="progress-bar" style="width: 45%"></div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="progress progress-striped active"&gt;
&lt;div class="progress-bar" style="width: 40%;"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="progress progress-striped active">
<div class="progress-bar" style="width: 45%"></div>
</div>
{% endhighlight %}
<h3>Stacked</h3>
<p>Place multiple bars into the same <code>.progress</code> to stack them.</p>
@ -1623,13 +1561,13 @@
<div class="progress-bar progress-bar-danger" style="width: 10%"></div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="progress"&gt;
&lt;div class="progress-bar progress-bar-success" style="width: 35%;"&gt;&lt;/div&gt;
&lt;div class="progress-bar progress-bar-warning" style="width: 20%;"&gt;&lt;/div&gt;
&lt;div class="progress-bar progress-bar-danger" style="width: 10%;"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 35%"></div>
<div class="progress-bar progress-bar-warning" style="width: 20%"></div>
<div class="progress-bar progress-bar-danger" style="width: 10%"></div>
</div>
{% endhighlight %}
</section>
@ -1674,23 +1612,18 @@
</div>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="media"&gt;
&lt;a class="pull-left" href="#"&gt;
&lt;img class="media-object" data-src="holder.js/64x64"&gt;
&lt;/a&gt;
&lt;div class="media-body"&gt;
&lt;h4 class="media-heading"&gt;Media heading&lt;/h4&gt;
</div><!-- /.bs-docs-example -->
{% highlight html linenos %}
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="...">
</a>
<div class="media-body">
<h4 class="media-heading">Media heading</h4>
...
&lt;!-- Nested media object --&gt;
&lt;div class="media"&gt;
...
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
</div>
</div>
{% endhighlight %}
<h3>Media list</h3>
<p>With a bit of extra markup, you can use media inside list (useful for comment threads or articles lists).</p>
@ -1746,24 +1679,19 @@
</li>
</ul>
</div>
<pre class="prettyprint linenums">
&lt;ul class="media-list"&gt;
&lt;li class="media"&gt;
&lt;a class="pull-left" href="#"&gt;
&lt;img class="media-object" data-src="holder.js/64x64"&gt;
&lt;/a&gt;
&lt;div class="media-body"&gt;
&lt;h4 class="media-heading"&gt;Media heading&lt;/h4&gt;
{% highlight html linenos %}
<ul class="media-list">
<li class="media">
<a class="pull-left" href="#">
<img class="media-object" src="...">
</a>
<div class="media-body">
<h4 class="media-heading">Media heading</h4>
...
&lt;!-- Nested media object --&gt;
&lt;div class="media"&gt;
...
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div>
</li>
</ul>
{% endhighlight %}
</section>
@ -1785,11 +1713,9 @@
Look, I'm in a well!
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="well"&gt;
...
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="well">...</div>
{% endhighlight %}
<h3>Optional classes</h3>
<p>Control padding and rounded corners with two optional modifier classes.</p>
<div class="bs-docs-example">
@ -1797,73 +1723,72 @@
Look, I'm in a well!
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="well well-large"&gt;
...
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="well well-large">...</div>
{% endhighlight %}
<div class="bs-docs-example">
<div class="well well-small">
Look, I'm in a well!
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="well well-small"&gt;
...
&lt;/div&gt;
</pre>
{% highlight html linenos %}
<div class="well well-small">...</div>
{% endhighlight %}
<h2>Close icon</h2>
<p>Use the generic close icon for dismissing content like modals and alerts.</p>
<div class="bs-docs-example">
<p><button class="close" style="float: none;">&times;</button></p>
</div>
<pre class="prettyprint linenums">&lt;button class="close"&gt;&amp;times;&lt;/button&gt;</pre>
<p>iOS devices require an <code>href="#"</code> for click events if you would rather use an anchor.</p>
<pre class="prettyprint linenums">&lt;a class="close" href="#"&gt;&amp;times;&lt;/a&gt;</pre>
{% highlight html linenos %}
<button class="close" style="float: none;">&times;</button>
{% endhighlight %}
<h2>Helper classes</h2>
<p>Simple, focused classes for small display or behavior tweaks.</p>
<h4>.pull-left</h4>
<p>Float an element left</p>
<pre class="prettyprint linenums">
class="pull-left"
</pre>
<pre class="prettyprint linenums">
{% highlight html linenos %}
<div class="pull-left">...</div>
{% endhighlight %}
{% highlight css linenos %}
.pull-left {
float: left;
}
</pre>
{% endhighlight %}
<h4>.pull-right</h4>
<p>Float an element right</p>
<pre class="prettyprint linenums">
class="pull-right"
</pre>
<pre class="prettyprint linenums">
{% highlight html linenos %}
<div class="pull-right">...</div>
{% endhighlight %}
{% highlight css linenos %}
.pull-right {
float: right;
}
</pre>
{% endhighlight %}
<h4>.muted</h4>
<p>Change an element's color to <code>#999</code></p>
<pre class="prettyprint linenums">
class="muted"
</pre>
<pre class="prettyprint linenums">
{% highlight html linenos %}
<p class="muted">...</p>
{% endhighlight %}
{% highlight css linenos %}
.muted {
color: #999;
}
</pre>
{% endhighlight %}
<h4>.clearfix</h4>
<p>Clear the <code>float</code> on any element. Utilizes <a href="http://nicolasgallagher.com/micro-clearfix-hack/">the micro clearfix</a> as popularized by Nicolas Gallagher.</p>
<pre class="prettyprint linenums">
class="clearfix"
</pre>
<pre class="prettyprint linenums">
{% highlight html linenos %}
<div class="clearfix">...</div>
{% endhighlight %}
{% highlight css linenos %}
.clearfix {
&:before,
&:after {
@ -1874,81 +1799,14 @@ class="clearfix"
clear: both;
}
}
</pre>
{% endhighlight %}
</section>
</div>
</div>
</div><!-- /span9 -->
</div><!-- row -->
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
</body>
</html>
</div><!-- /.container -->

View File

@ -1,70 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Customize · Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: default
title: Customize and download
---
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="">
<a href="./index.html">Home</a>
</li>
<li class="">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="">
<a href="./components.html">Components</a>
</li>
<li class="">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="active">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
<!-- Masthead
================================================== -->
@ -423,7 +361,7 @@
</h1>
</div>
<div class="download-btn">
<a class="btn btn-primary" href="#" >Customize and Download</a>
<a class="btn btn-primary" href="#" onclick="_gaq.push(['_trackEvent', 'Customize', 'Download', 'Customize and Download']);">Customize and Download</a>
<h4>What's included?</h4>
<p>Downloads include compiled CSS, compiled and minified CSS, and compiled jQuery plugins, all nicely packed up into a zipball for your convenience.</p>
</div>
@ -432,75 +370,7 @@
</div>
</div>
</div><!-- /span9 -->
</div><!-- row -->
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
</body>
</html>
</div><!-- /.container -->

View File

@ -1,454 +1,403 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Carousel Template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Carousel template
---
<!-- Le styles -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<link href="../assets/css/bootstrap-responsive.css" rel="stylesheet">
<style>
<!-- Custom styles for this template -->
<style>
/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */
/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */
body {
padding-bottom: 40px;
color: #5a5a5a;
}
body {
padding-bottom: 40px;
color: #5a5a5a;
}
/* CUSTOMIZE THE NAVBAR
-------------------------------------------------- */
/* CUSTOMIZE THE NAVBAR
-------------------------------------------------- */
/* Special class on .container surrounding .navbar, used for positioning it into place. */
.navbar-wrapper {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 10;
margin-top: 20px;
margin-bottom: -90px; /* Negative margin to pull up carousel. 90px is roughly margins and height of navbar. */
}
.navbar-wrapper .navbar {
/* Special class on .container surrounding .navbar, used for positioning it into place. */
.navbar-wrapper {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 10;
margin-top: 20px;
margin-bottom: -90px; /* Negative margin to pull up carousel. 90px is roughly margins and height of navbar. */
}
.navbar-wrapper .navbar {
}
}
/* Remove border and change up box shadow for more contrast */
.navbar .navbar-inner {
border: 0;
-webkit-box-shadow: 0 2px 10px rgba(0,0,0,.25);
-moz-box-shadow: 0 2px 10px rgba(0,0,0,.25);
box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
/* Remove border and change up box shadow for more contrast */
.navbar .navbar-inner {
border: 0;
-webkit-box-shadow: 0 2px 10px rgba(0,0,0,.25);
-moz-box-shadow: 0 2px 10px rgba(0,0,0,.25);
box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
/* Downsize the brand/project name a bit */
.navbar .brand {
padding: 14px 20px 16px; /* Increase vertical padding to match navbar links */
font-size: 16px;
font-weight: bold;
text-shadow: 0 -1px 0 rgba(0,0,0,.5);
}
/* Downsize the brand/project name a bit */
.navbar .brand {
padding: 14px 20px 16px; /* Increase vertical padding to match navbar links */
font-size: 16px;
font-weight: bold;
text-shadow: 0 -1px 0 rgba(0,0,0,.5);
}
/* Navbar links: increase padding for taller navbar */
.navbar .nav > li > a {
padding: 15px 20px;
}
/* Navbar links: increase padding for taller navbar */
.navbar .nav > li > a {
padding: 15px 20px;
}
/* Offset the responsive button for proper vertical alignment */
.navbar .btn-navbar {
margin-top: 10px;
}
/* Offset the responsive button for proper vertical alignment */
.navbar .btn-navbar {
margin-top: 10px;
}
/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */
/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */
/* Carousel base class */
.carousel {
margin-bottom: 60px;
}
/* Carousel base class */
.carousel {
margin-bottom: 60px;
}
.carousel .container {
position: relative;
z-index: 9;
}
.carousel .container {
position: relative;
z-index: 9;
}
.carousel-control {
height: 80px;
margin-top: 0;
font-size: 120px;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
background-color: transparent;
border: 0;
z-index: 10;
}
.carousel-control {
height: 80px;
margin-top: 0;
font-size: 120px;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
background-color: transparent;
border: 0;
z-index: 10;
}
.carousel .item {
height: 500px;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: 500px;
}
.carousel .item {
height: 500px;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: 500px;
}
.carousel-caption {
background-color: transparent;
position: static;
max-width: 550px;
padding: 0 20px;
margin-top: 200px;
}
.carousel-caption h1,
.carousel-caption .lead {
margin: 0;
line-height: 1.25;
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.carousel-caption .btn {
margin-top: 10px;
}
.carousel-caption {
background-color: transparent;
position: static;
max-width: 550px;
padding: 0 20px;
margin-top: 200px;
}
.carousel-caption h1,
.carousel-caption .lead {
margin: 0;
line-height: 1.25;
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.carousel-caption .btn {
margin-top: 10px;
}
/* MARKETING CONTENT
-------------------------------------------------- */
/* MARKETING CONTENT
-------------------------------------------------- */
/* Center align the text within the three columns below the carousel */
.marketing .span4 {
text-align: center;
}
.marketing h2 {
font-weight: normal;
}
.marketing .span4 p {
margin-left: 10px;
margin-right: 10px;
}
/* Center align the text within the three columns below the carousel */
.marketing .span4 {
text-align: center;
}
.marketing h2 {
font-weight: normal;
}
.marketing .span4 p {
margin-left: 10px;
margin-right: 10px;
}
/* Featurettes
------------------------- */
/* Featurettes
------------------------- */
.featurette-divider {
margin: 80px 0; /* Space out the Bootstrap <hr> more */
}
.featurette {
padding-top: 120px; /* Vertically center images part 1: add padding above and below text. */
overflow: hidden; /* Vertically center images part 2: clear their floats. */
}
.featurette-image {
margin-top: -120px; /* Vertically center images part 3: negative margin up the image the same amount of the padding to center it. */
}
.featurette-divider {
margin: 80px 0; /* Space out the Bootstrap <hr> more */
}
.featurette {
padding-top: 120px; /* Vertically center images part 1: add padding above and below text. */
overflow: hidden; /* Vertically center images part 2: clear their floats. */
}
.featurette-image {
margin-top: -120px; /* Vertically center images part 3: negative margin up the image the same amount of the padding to center it. */
}
/* Give some space on the sides of the floated elements so text doesn't run right into it. */
.featurette-image.pull-left {
margin-right: 40px;
}
.featurette-image.pull-right {
margin-left: 40px;
}
/* Give some space on the sides of the floated elements so text doesn't run right into it. */
.featurette-image.pull-left {
margin-right: 40px;
}
.featurette-image.pull-right {
margin-left: 40px;
}
/* Thin out the marketing headings */
.featurette-heading {
font-size: 50px;
font-weight: 300;
line-height: 1;
letter-spacing: -1px;
}
/* Thin out the marketing headings */
.featurette-heading {
font-size: 50px;
font-weight: 300;
line-height: 1;
letter-spacing: -1px;
}
/* RESPONSIVE CSS
-------------------------------------------------- */
/* RESPONSIVE CSS
-------------------------------------------------- */
@media (max-width: 979px) {
@media (max-width: 979px) {
.container.navbar-wrapper {
margin-bottom: 0;
width: auto;
}
.navbar-inner {
border-radius: 0;
margin: -20px 0;
}
.container.navbar-wrapper {
margin-bottom: 0;
width: auto;
}
.navbar-inner {
border-radius: 0;
margin: -20px 0;
}
.carousel .item {
height: 500px;
}
.carousel img {
width: auto;
height: 500px;
}
.carousel .item {
height: 500px;
}
.carousel img {
width: auto;
height: 500px;
}
.featurette {
height: auto;
padding: 0;
}
.featurette-image.pull-left,
.featurette-image.pull-right {
display: block;
float: none;
max-width: 40%;
margin: 0 auto 20px;
}
}
.featurette {
height: auto;
padding: 0;
}
.featurette-image.pull-left,
.featurette-image.pull-right {
display: block;
float: none;
max-width: 40%;
margin: 0 auto 20px;
}
}
@media (max-width: 767px) {
@media (max-width: 767px) {
.navbar-inner {
margin: -20px;
}
.navbar-inner {
margin: -20px;
}
.carousel {
margin-left: -20px;
margin-right: -20px;
}
.carousel .container {
.carousel {
margin-left: -20px;
margin-right: -20px;
}
.carousel .container {
}
.carousel .item {
height: 300px;
}
.carousel img {
height: 300px;
}
.carousel-caption {
width: 65%;
padding: 0 70px;
margin-top: 100px;
}
.carousel-caption h1 {
font-size: 30px;
}
.carousel-caption .lead,
.carousel-caption .btn {
font-size: 18px;
}
}
.carousel .item {
height: 300px;
}
.carousel img {
height: 300px;
}
.carousel-caption {
width: 65%;
padding: 0 70px;
margin-top: 100px;
}
.carousel-caption h1 {
font-size: 30px;
}
.carousel-caption .lead,
.carousel-caption .btn {
font-size: 18px;
}
.marketing .span4 + .span4 {
margin-top: 40px;
}
.marketing .span4 + .span4 {
margin-top: 40px;
}
.featurette-heading {
font-size: 30px;
}
.featurette .lead {
font-size: 18px;
line-height: 1.5;
}
.featurette-heading {
font-size: 30px;
}
.featurette .lead {
font-size: 18px;
line-height: 1.5;
}
}
</style>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
</head>
<body>
}
</style>
<!-- NAVBAR
================================================== -->
<div class="navbar-wrapper">
<!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
<div class="container">
<!-- NAVBAR
================================================== -->
<div class="navbar-wrapper">
<!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
<div class="container">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<!-- Read about Bootstrap dropdowns at http://twitter.github.com/bootstrap/javascript.html#dropdowns -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<!-- Read about Bootstrap dropdowns at http://twitter.github.com/bootstrap/javascript.html#dropdowns -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar -->
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar -->
</div> <!-- /.container -->
</div><!-- /.navbar-wrapper -->
</div> <!-- /.container -->
</div><!-- /.navbar-wrapper -->
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="../assets/img/examples/slide-01.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>Example headline.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Sign up today</a>
</div>
</div>
</div>
<div class="item">
<img src="../assets/img/examples/slide-02.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>Another example headline.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Learn more</a>
</div>
</div>
</div>
<div class="item">
<img src="../assets/img/examples/slide-03.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>One more for good measure.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Browse gallery</a>
</div>
</div>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="../assets/img/examples/slide-01.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>Example headline.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Sign up today</a>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div><!-- /.carousel -->
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing">
<!-- Three columns of text below the carousel -->
<div class="row">
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
</div><!-- /.row -->
<!-- START THE FEATURETTES -->
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-right" src="../assets/img/examples/browser-icon-chrome.png">
<h2 class="featurette-heading">First featurette headling. <span class="muted">It'll blow your mind.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<div class="item">
<img src="../assets/img/examples/slide-02.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>Another example headline.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Learn more</a>
</div>
</div>
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-left" src="../assets/img/examples/browser-icon-firefox.png">
<h2 class="featurette-heading">Oh yeah, it's that good. <span class="muted">See for yourself.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<div class="item">
<img src="../assets/img/examples/slide-03.jpg" alt="">
<div class="container">
<div class="carousel-caption">
<h1>One more for good measure.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Browse gallery</a>
</div>
</div>
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-right" src="../assets/img/examples/browser-icon-safari.png">
<h2 class="featurette-heading">And lastly, this one. <span class="muted">Checkmate.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<hr class="featurette-divider">
<!-- /END THE FEATURETTES -->
<!-- FOOTER -->
<footer>
<p class="pull-right"><a href="#">Back to top</a></p>
<p>&copy; 2013 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
</div><!-- /.container -->
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div><!-- /.carousel -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
<script>
!function ($) {
$(function(){
// carousel demo
$('#myCarousel').carousel()
})
}(window.jQuery)
</script>
<script src="../assets/js/holder/holder.js"></script>
</body>
</html>
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing">
<!-- Three columns of text below the carousel -->
<div class="row">
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
<div class="span4">
<img class="img-circle" data-src="holder.js/140x140">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div><!-- /.span4 -->
</div><!-- /.row -->
<!-- START THE FEATURETTES -->
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-right" src="../assets/img/examples/browser-icon-chrome.png">
<h2 class="featurette-heading">First featurette headling. <span class="muted">It'll blow your mind.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-left" src="../assets/img/examples/browser-icon-firefox.png">
<h2 class="featurette-heading">Oh yeah, it's that good. <span class="muted">See for yourself.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<hr class="featurette-divider">
<div class="featurette">
<img class="featurette-image pull-right" src="../assets/img/examples/browser-icon-safari.png">
<h2 class="featurette-heading">And lastly, this one. <span class="muted">Checkmate.</span></h2>
<p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
</div>
<hr class="featurette-divider">
<!-- /END THE FEATURETTES -->
<!-- FOOTER -->
<footer>
<p class="pull-right"><a href="#">Back to top</a></p>
<p>&copy; 2013 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
</div><!-- /.container -->

View File

@ -1,173 +1,128 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Narrow page template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Narrow page template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
/* Space out content a bit */
body {
padding-top: 20px;
padding-bottom: 20px;
}
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
/* Everything but the jumbotron gets side spacing for mobile-first views */
.masthead,
.marketing,
.footer {
padding-left: 15px;
padding-right: 15px;
}
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
/* Custom page header */
.masthead {
border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.masthead h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
padding-bottom: 19px;
}
<!-- Custom styles for this template -->
<style>
/* Space out content a bit */
body {
padding-top: 20px;
padding-bottom: 20px;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 700px;
}
.container-narrow > hr {
margin: 30px 0;
}
/* Everything but the jumbotron gets side spacing for mobile-first views */
.masthead,
.marketing,
.footer {
padding-left: 15px;
padding-right: 15px;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
}
.jumbotron h1 {
font-size: 72px;
line-height: 1;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Custom page header */
.masthead {
border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.masthead h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
padding-bottom: 19px;
}
/* Supporting marketing content */
.marketing {
margin: 40px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 700px;
}
.container-narrow > hr {
margin: 30px 0;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
}
.jumbotron h1 {
font-size: 72px;
line-height: 1;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 40px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-left: 0;
padding-right: 0;
}
/* Space out the masthead */
.masthead {
margin-bottom: 30px;
}
}
</style>
</head>
<body>
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-left: 0;
padding-right: 0;
}
/* Space out the masthead */
.masthead {
margin-bottom: 30px;
}
}
</style>
<div class="container-narrow">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<h3 class="muted">Project name</h3>
</div>
<div class="container-narrow">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<h3 class="muted">Project name</h3>
</div>
<div class="jumbotron">
<h1>Super awesome marketing speak!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-large btn-success" href="#">Sign up today</a></p>
</div>
<div class="jumbotron">
<h1>Super awesome marketing speak!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-large btn-success" href="#">Sign up today</a></p>
</div>
<div class="row marketing">
<div class="span6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<div class="row marketing">
<div class="span6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
<div class="span6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<div class="span6">
<h4>Subheading</h4>
<p>Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cras mattis consectetur purus sit amet fermentum.</p>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
</div>
<h4>Subheading</h4>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</div>
</div>
<hr>
<hr>
<div class="footer">
<p>&copy; Company 2013</p>
</div>
<div class="footer">
<p>&copy; Company 2013</p>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
</div> <!-- /container -->

View File

@ -1,157 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jumbotron template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Jumbotron template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
padding-bottom: 20px;
}
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
/* Set widths on the navbar form inputs since otherwise they're 100% wide */
.navbar-form input[type="text"],
.navbar-form input[type="password"] {
width: 180px;
}
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
<!-- Custom styles for this template -->
<style>
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Let the jumbotron breathe */
.jumbotron {
margin-top: 20px;
}
/* Remove padding from wrapping element since we kick in the grid classes here */
.body-content {
padding: 0;
}
}
</style>
/* Set widths on the navbar form inputs since otherwise they're 100% wide */
.navbar-form input[type="text"],
.navbar-form input[type="password"] {
width: 180px;
}
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Let the jumbotron breathe */
.jumbotron {
margin-top: 20px;
}
/* Remove padding from wrapping element since we kick in the grid classes here */
.body-content {
padding: 0;
}
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
<form class="navbar-form pull-right">
<input type="text" placeholder="Email">
<input type="password" placeholder="Password">
<button type="submit" class="btn">Sign in</button>
</form>
</div><!--/.nav-collapse -->
</li>
</ul>
<form class="navbar-form pull-right">
<input type="text" placeholder="Email">
<input type="password" placeholder="Password">
<button type="submit" class="btn">Sign in</button>
</form>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>
<div class="body-content">
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>
<div class="container">
<hr>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>
<footer>
<p>&copy; Company 2013</p>
</footer>
</div>
<div class="body-content">
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>
<hr>
<footer>
<p>&copy; Company 2013</p>
</footer>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
</div> <!-- /container -->

View File

@ -1,197 +1,146 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Justified nav template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Justified nav template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
body {
padding-top: 20px;
}
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
/* Everything but the jumbotron gets side spacing for mobile-first views */
.masthead,
.body-content,
.footer {
padding-left: 15px;
padding-right: 15px;
}
<!-- Custom styles for this template -->
<style>
.footer {
border-top: 1px solid #ddd;
margin-top: 30px;
padding-top: 29px;
padding-bottom: 30px;
}
body {
padding-top: 20px;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Everything but the jumbotron gets side spacing for mobile-first views */
.masthead,
.body-content,
.footer {
padding-left: 15px;
padding-right: 15px;
}
/* Custom container */
/* .container > hr {
margin: 60px 0;
}
*/
.footer {
border-top: 1px solid #ddd;
margin-top: 30px;
padding-top: 29px;
padding-bottom: 30px;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.nav-justified {
max-height: 50px;
background-color: #eee;
border-radius: 5px;
border: 1px solid #ccc;
}
.nav-justified li a {
padding-top: 15px;
padding-bottom: 15px;
color: #777;
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255,255,255,.75);
border-right: 1px solid rgba(0,0,0,.1);
background-color: #e5e5e5; /* Old browsers */
background-repeat: repeat-x; /* Repeat the gradient */
background-image: -moz-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* Chrome 10+,Safari 5.1+ */
background-image: -ms-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* IE10+ */
background-image: -o-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* Opera 11.10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background-image: linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* W3C */
}
.nav-justified .active a {
background-color: #ddd;
background-image: none;
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified li:first-child a {
border-left: 0;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.nav-justified li:last-child a {
border-right: 0;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.nav-justified {
max-height: 50px;
background-color: #eee;
border-radius: 5px;
border: 1px solid #ccc;
}
.nav-justified li a {
padding-top: 15px;
padding-bottom: 15px;
color: #777;
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255,255,255,.75);
border-right: 1px solid rgba(0,0,0,.1);
background-color: #e5e5e5; /* Old browsers */
background-repeat: repeat-x; /* Repeat the gradient */
background-image: -moz-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background-image: -webkit-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* Chrome 10+,Safari 5.1+ */
background-image: -ms-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* IE10+ */
background-image: -o-linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* Opera 11.10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background-image: linear-gradient(top, #f5f5f5 0%,#e5e5e5 100%); /* W3C */
}
.nav-justified .active a {
background-color: #ddd;
background-image: none;
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified li:first-child a {
border-left: 0;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.nav-justified li:last-child a {
border-right: 0;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-left: 0;
padding-right: 0;
}
/* Make the nav on the same line */
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-left: 0;
padding-right: 0;
}
/* Make the nav on the same line */
}
</style>
</head>
<body>
</style>
<div class="container">
<div class="container">
<div class="masthead">
<h3 class="muted">Project name</h3>
<ul class="nav nav-justified">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="masthead">
<h3 class="muted">Project name</h3>
<ul class="nav nav-justified">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<!-- Jumbotron -->
<div class="jumbotron">
<h1>Marketing stuff!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet.</p>
<p><a class="btn btn-large btn-success" href="#">Get started today</a></p>
</div>
<div class="body-content">
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<!-- Jumbotron -->
<div class="jumbotron">
<h1>Marketing stuff!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet.</p>
<p><a class="btn btn-large btn-success" href="#">Get started today</a></p>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>
</div><!-- /.body-content -->
<div class="body-content">
<!-- Site footer -->
<div class="footer">
<p>&copy; Company 2013</p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>
</div><!-- /.body-content -->
<!-- Site footer -->
<div class="footer">
<p>&copy; Company 2013</p>
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
</div> <!-- /container -->

View File

@ -1,113 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sign in form template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Sign in form template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
.form-signin {
max-width: 300px;
padding: 30px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin input[type="text"],
.form-signin input[type="password"] {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin input[type="text"]:focus,
.form-signin input[type="password"]:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
<!-- Custom styles for this template -->
<style>
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}
.form-signin {
max-width: 300px;
padding: 30px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin input[type="text"],
.form-signin input[type="password"] {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin input[type="text"]:focus,
.form-signin input[type="password"]:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
</style>
</head>
<body>
</style>
<div class="container">
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="input-block-level" placeholder="Email address" autofocus>
<input type="password" class="input-block-level" placeholder="Password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-large btn-primary btn-block" type="submit">Sign in</button>
</form>
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="input-block-level" placeholder="Email address" autofocus>
<input type="password" class="input-block-level" placeholder="Password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-large btn-primary btn-block" type="submit">Sign in</button>
</form>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
</div> <!-- /container -->

View File

@ -1,87 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Starter template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Starter template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
body {
padding-top: 50px;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
<!-- Custom styles for this template -->
<style>
body {
padding-top: 50px;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>
<div class="container">
</div><!-- /container -->
<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
</div><!-- /container -->

View File

@ -1,162 +1,117 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sticky footer with navbar template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Sticky footer with navbar template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
/* Sticky footer styles
-------------------------------------------------- */
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
<!-- Custom styles for this template -->
<style>
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Sticky footer styles
-------------------------------------------------- */
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap > .container {
padding-top: 60px;
}
.container .credit {
margin: 20px 0;
}
#wrap > .container {
padding-top: 60px;
}
.container .credit {
margin: 20px 0;
}
code {
font-size: 80%;
}
code {
font-size: 80%;
}
</style>
</head>
<body>
</style>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">Project name</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer with fixed navbar</h1>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added within <code>#wrap</code> with <code>padding-top: 60px;</code> on the <code>.container</code>.</p>
<p>Back to <a href="./sticky-footer.html">the default sticky footer</a> minus the navbar.</p>
</div>
<div id="push"></div>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">Example courtesy <a href="http://martinbean.co.uk">Martin Bean</a> and <a href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer with fixed navbar</h1>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added within <code>#wrap</code> with <code>padding-top: 60px;</code> on the <code>.container</code>.</p>
<p>Back to <a href="./sticky-footer.html">the default sticky footer</a> minus the navbar.</p>
</div>
<div id="push"></div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
<div id="footer">
<div class="container">
<p class="muted credit">Example courtesy <a href="http://martinbean.co.uk">Martin Bean</a> and <a href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
</div>

View File

@ -1,126 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sticky footer template &middot; Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
---
layout: example
title: Sticky footer template
---
<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<script src="../assets/js/respond/respond.min.js"></script>
<![endif]-->
/* Sticky footer styles
-------------------------------------------------- */
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../assets/ico/favicon.png">
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
<!-- Custom styles for this template -->
<style>
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Sticky footer styles
-------------------------------------------------- */
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
.container {
width: auto;
max-width: 680px;
}
.container .credit {
margin: 20px 0;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
.container {
width: auto;
max-width: 680px;
}
.container .credit {
margin: 20px 0;
}
</style>
</head>
<body>
</style>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer</h1>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>
<p>Use <a href="./sticky-footer-navbar.html">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
<div id="push"></div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer</h1>
</div>
<p class="lead">Pin a fixed-height footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>
<p>Use <a href="./sticky-footer-navbar.html">the sticky footer with a fixed navbar</a> if need be, too.</p>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">Example courtesy <a href="http://martinbean.co.uk">Martin Bean</a> and <a href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
</div>
<div id="push"></div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../assets/js/jquery.js"></script>
<script src="../assets/js/bootstrap-transition.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
<div id="footer">
<div class="container">
<p class="muted credit">Example courtesy <a href="http://martinbean.co.uk">Martin Bean</a> and <a href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
</div>

View File

@ -1,70 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gallery · Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="">
<a href="./index.html">Home</a>
</li>
<li class="">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="">
<a href="./components.html">Components</a>
</li>
<li class="">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
---
layout: default
title: Gallery
---
<!-- Subhead
================================================== -->
@ -82,174 +19,101 @@
<div class="row">
<div class="span4">
<a class="thumbnail" href="https://gosquared.com">
<img src="assets/img/example-sites/example-gosquared.jpg">
<img src="/assets/img/example-sites/example-gosquared.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="https://easel.com">
<img src="assets/img/example-sites/example-easel.jpg">
<img src="/assets/img/example-sites/example-easel.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="https://tonx.com">
<img src="assets/img/example-sites/example-tonx.jpg">
<img src="/assets/img/example-sites/example-tonx.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="https://jshint.com">
<img src="assets/img/example-sites/example-jshint.jpg">
<img src="/assets/img/example-sites/example-jshint.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="https://synco.fm">
<img src="assets/img/example-sites/example-synco.jpg">
<img src="/assets/img/example-sites/example-synco.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="https://yourkarma.com">
<img src="assets/img/example-sites/example-karma.jpg">
<img src="/assets/img/example-sites/example-karma.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://metrotwit.com">
<img src="assets/img/example-sites/example-metrotwit.jpg">
<img src="/assets/img/example-sites/example-metrotwit.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://codecademy.com">
<img src="assets/img/example-sites/example-codecademy.jpg">
<img src="/assets/img/example-sites/example-codecademy.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://jetstrap.com">
<img src="assets/img/example-sites/example-jetstrap.jpg">
<img src="/assets/img/example-sites/example-jetstrap.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://divshot.com">
<img src="assets/img/example-sites/example-divshot.jpg">
<img src="/assets/img/example-sites/example-divshot.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://translate.twttr.com">
<img src="assets/img/example-sites/example-twitter-translation-center.jpg">
<img src="/assets/img/example-sites/example-twitter-translation-center.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://soundready.fm">
<img src="assets/img/example-sites/example-soundready.jpg">
<img src="/assets/img/example-sites/example-soundready.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://breakingnews.com">
<img src="assets/img/example-sites/example-breakingnews.jpg">
<img src="/assets/img/example-sites/example-breakingnews.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://desk.com">
<img src="assets/img/example-sites/example-desk.jpg">
<img src="/assets/img/example-sites/example-desk.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://jumpstartui.com">
<img src="assets/img/example-sites/example-jumpstart-ui.jpg">
<img src="/assets/img/example-sites/example-jumpstart-ui.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://atheycreek.com">
<img src="assets/img/example-sites/example-athey-creek.jpg">
<img src="/assets/img/example-sites/example-athey-creek.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://fleetio.com">
<img src="assets/img/example-sites/example-fleetio.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://breakingnews.com">
<img src="assets/img/example-sites/example-breakingnews.jpg">
<img src="/assets/img/example-sites/example-fleetio.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://adoptahydrant.com">
<img src="assets/img/example-sites/example-adoptahydrant.jpg">
<img src="/assets/img/example-sites/example-adoptahydrant.jpg">
</a>
</div>
<div class="span4">
<a class="thumbnail" href="http://8020select.com">
<img src="assets/img/example-sites/example-8020select.jpg">
<img src="/assets/img/example-sites/example-8020select.jpg">
</a>
</div>
</div>
</div><!-- /.row -->
</section>
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
</body>
</html>
</div><!-- /.container -->

View File

@ -1,70 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Getting · Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="">
<a href="./index.html">Home</a>
</li>
<li class="active">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="">
<a href="./components.html">Components</a>
</li>
<li class="">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
---
layout: default
title: Getting started
description: Overview of the project, its contents, and how to get started with a simple template.
---
<!-- Subhead
================================================== -->
@ -76,58 +14,59 @@
</header>
<div class="container">
<div class="container">
<!-- Docs nav
================================================== -->
<div class="row">
<div class="span3 bs-docs-sidebar">
<ul class="nav nav-list bs-docs-sidenav">
<li><a href="#download-bootstrap"><i class="glyphicon-chevron-right"></i> Download</a></li>
<li><a href="#file-structure"><i class="glyphicon-chevron-right"></i> File structure</a></li>
<li><a href="#contents"><i class="glyphicon-chevron-right"></i> What's included</a></li>
<li><a href="#html-template"><i class="glyphicon-chevron-right"></i> HTML template</a></li>
<li><a href="#examples"><i class="glyphicon-chevron-right"></i> Examples</a></li>
<li><a href="#what-next"><i class="glyphicon-chevron-right"></i> What next?</a></li>
</ul>
</div>
<div class="span9">
<!-- Docs nav
================================================== -->
<div class="row">
<div class="span3 bs-docs-sidebar">
<ul class="nav nav-list bs-docs-sidenav">
<li><a href="#download-bootstrap"><i class="glyphicon-chevron-right"></i> Download</a></li>
<li><a href="#file-structure"><i class="glyphicon-chevron-right"></i> File structure</a></li>
<li><a href="#contents"><i class="glyphicon-chevron-right"></i> What's included</a></li>
<li><a href="#html-template"><i class="glyphicon-chevron-right"></i> HTML template</a></li>
<li><a href="#examples"><i class="glyphicon-chevron-right"></i> Examples</a></li>
<li><a href="#what-next"><i class="glyphicon-chevron-right"></i> What next?</a></li>
</ul>
</div>
<div class="span9">
<!-- Download
================================================== -->
<section id="download-bootstrap">
<div class="page-header">
<h1>1. Download</h1>
<!-- Download
================================================== -->
<section id="download-bootstrap">
<div class="page-header">
<h1>1. Download</h1>
</div>
<p class="lead">Before downloading, be sure to have a code editor (we recommend <a href="http://sublimetext.com/2">Sublime Text 2</a>) and some working knowledge of HTML and CSS. We won't walk through the source files here, but they are available for download. We'll focus on getting started with the compiled Bootstrap files.</p>
<div class="row">
<div class="span6">
<h2>Download compiled</h2>
<p><strong>Fastest way to get started:</strong> get the compiled and minified versions of our CSS, JS, and images. No docs or original source files.</p>
<p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download compiled']);">Download Bootstrap</a></p>
</div>
<p class="lead">Before downloading, be sure to have a code editor (we recommend <a href="http://sublimetext.com/2">Sublime Text 2</a>) and some working knowledge of HTML and CSS. We won't walk through the source files here, but they are available for download. We'll focus on getting started with the compiled Bootstrap files.</p>
<div class="row">
<div class="span6">
<h2>Download compiled</h2>
<p><strong>Fastest way to get started:</strong> get the compiled and minified versions of our CSS, JS, and images. No docs or original source files.</p>
<p><a class="btn btn-large btn-primary" href="assets/bootstrap.zip" >Download Bootstrap</a></p>
</div>
<div class="span6">
<h2>Download source</h2>
<p>Get the original files for all CSS and JavaScript, along with a local copy of the docs by downloading the latest version directly from GitHub.</p>
<p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" >Download Bootstrap source</a></p>
</div>
<div class="span6">
<h2>Download source</h2>
<p>Get the original files for all CSS and JavaScript, along with a local copy of the docs by downloading the latest version directly from GitHub.</p>
<p><a class="btn btn-large" href="https://github.com/twitter/bootstrap/zipball/master" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Download', 'Download source']);">Download Bootstrap source</a></p>
</div>
</section>
</div>
</section>
<!-- File structure
================================================== -->
<section id="file-structure">
<div class="page-header">
<h1>2. File structure</h1>
</div>
<p class="lead">Within the download you'll find the following file structure and contents, logically grouping common assets and providing both compiled and minified variations.</p>
<p>Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:</p>
<pre class="prettyprint">
<!-- File structure
================================================== -->
<section id="file-structure">
<div class="page-header">
<h1>2. File structure</h1>
</div>
<p class="lead">Within the download you'll find the following file structure and contents, logically grouping common assets and providing both compiled and minified variations.</p>
<p>Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:</p>
{% highlight bash %}
bootstrap/
├── css/
│ ├── bootstrap.css
@ -141,240 +80,177 @@
├── glyphiconshalflings-regular.svg
├── glyphiconshalflings-regular.ttf
└── glyphiconshalflings-regular.woff
</pre>
<p>This is the most basic form of Bootstrap: compiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (<code>bootstrap.*</code>), as well as compiled and minified CSS and JS (<code>bootstrap.min.*</code>). The image files are compressed using <a href="http://imageoptim.com/">ImageOptim</a>, a Mac app for compressing PNGs.</p>
<p>Please note that <strong>all JavaScript plugins require jQuery</strong> to be included.</p>
</section>
{% endhighlight %}
<p>This is the most basic form of Bootstrap: compiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (<code>bootstrap.*</code>), as well as compiled and minified CSS and JS (<code>bootstrap.min.*</code>). The image files are compressed using <a href="http://imageoptim.com/">ImageOptim</a>, a Mac app for compressing PNGs.</p>
<p>Please note that <strong>all JavaScript plugins require jQuery</strong> to be included.</p>
</section>
<!-- Contents
================================================== -->
<section id="contents">
<div class="page-header">
<h1>3. What's included</h1>
</div>
<p class="lead">Bootstrap comes equipped with HTML, CSS, and JS for all sorts of things, but they can be summarized with a handful of categories visible at the top of the <a href="http://getbootstrap.com">Bootstrap documentation</a>.</p>
<h2>Docs sections</h2>
<p>In addition to the getting started documentation you're reading now, the Bootstrap docs are broken into a few key pages.</p>
<h4><a href="http://twitter.github.com/bootstrap/css.html">Core CSS</a></h4>
<p>Global styles for the body, Normalize, links, grid system, tables, forms, buttons, icons, and more.</p>
<h4><a href="http://twitter.github.com/bootstrap/components.html">Components</a></h4>
<p>Basic styles for common interface components like tabs and pills, navbar, alerts, page headers, and more. Head here to see what kind of custom components Bootstrap has to offer beyond basic HTML elements.</p>
<h4><a href="http://twitter.github.com/bootstrap/javascript.html">JavaScript plugins</a></h4>
<p>Similar to Components, these JavaScript plugins are interactive components for things like tooltips, popovers, modals, and more.</p>
</section>
<!-- HTML template
================================================== -->
<section id="html-template">
<div class="page-header">
<h1>4. Basic HTML template</h1>
</div>
<p class="lead">With a brief intro into the contents out of the way, we can focus on putting Bootstrap to use. To do that, we'll utilize a basic HTML template that includes everything we mentioned in the <a href="./getting-started.html#file-structure">File structure</a>.</p>
<p>Now, here's a look at a <strong>typical HTML file</strong>:</p>
<pre class="prettyprint linenums">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Hello, world!&lt;/h1&gt;
&lt;script src="http://code.jquery.com/jquery.js"&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>To make this <strong>a Bootstrapped template</strong>, just include the appropriate CSS and JS files:</p>
<pre class="prettyprint linenums">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;!-- Bootstrap --&gt;
&lt;link href="css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Hello, world!&lt;/h1&gt;
&lt;script src="http://code.jquery.com/jquery.js"&gt;&lt;/script&gt;
&lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>And you're set!</strong> With those two files added, you can begin to develop any site or application with Bootstrap.</p>
<hr>
<h4>Responsive features in IE8</h4>
<p>Internet Explorer 8 lacks support for media queries, the method by which we deliver responsive CSS to folks. To enable that, you need to include a third party tool (which we include in the project repository) called <a href="https://github.com/scottjehl/Respond">Respond.js</a>.</p>
<pre class="prettyprint linenums">
&lt;!--[if lt IE 9]&gt;
&lt;script src="assets/js/respond/respond.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;
</pre>
</section>
<!-- Examples
================================================== -->
<section id="examples">
<div class="page-header">
<h1>5. Examples</h1>
</div>
<p class="lead">Move beyond the base template with a few example layouts. We encourage folks to iterate on these examples and not simply use them as an end result.</p>
<div class="row bs-docs-examples">
<div class="span4">
<a class="thumbnail" href="examples/starter-template.html">
<img src="assets/img/examples/bootstrap-example-starter.png" alt="">
</a>
<h4>Starter template</h4>
<p>A barebones HTML document with all the Bootstrap CSS and JavaScript included.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/jumbotron.html">
<img src="assets/img/examples/bootstrap-example-marketing.png" alt="">
</a>
<h4>Basic marketing site</h4>
<p>Featuring a hero unit for a primary message and three supporting elements.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/jumbotron-narrow.html">
<img src="assets/img/examples/bootstrap-example-jumbotron-narrow.png" alt="">
</a>
<h4>Narrow marketing</h4>
<p>Slim, lightweight marketing template for small projects or teams.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/justified-nav.html">
<img src="assets/img/examples/bootstrap-example-justified-nav.png" alt="">
</a>
<h4>Justified nav</h4>
<p>Marketing page with equal-width navigation links in a modified navbar.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/signin.html">
<img src="assets/img/examples/bootstrap-example-signin.png" alt="">
</a>
<h4>Sign in</h4>
<p>Barebones sign in form with custom, larger form controls and a flexible layout.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/sticky-footer.html">
<img src="assets/img/examples/bootstrap-example-sticky-footer.png" alt="">
</a>
<h4>Sticky footer</h4>
<p>Pin a fixed-height footer to the bottom of the user's viewport.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/sticky-footer.html">
<img src="assets/img/examples/bootstrap-example-sticky-footer.png" alt="">
</a>
<h4>Sticky footer w/ navbar</h4>
<p>Add a fixed navbar to the default sticky footer template.</p>
</div>
<div class="span4">
<a class="thumbnail" href="examples/carousel.html">
<img src="assets/img/examples/bootstrap-example-carousel.png" alt="">
</a>
<h4>Carousel jumbotron</h4>
<p>An interactive riff on the basic marketing site featuring a prominent carousel.</p>
</div>
</div>
</section>
<!-- Next
================================================== -->
<section id="what-next">
<div class="page-header">
<h1>What next?</h1>
</div>
<p class="lead">Head to the docs for information, examples, and code snippets, or take the next leap and customize Bootstrap for any upcoming project.</p>
<a class="btn btn-large btn-primary" href="./css.html" >Visit the Bootstrap docs</a>
<a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" >Customize Bootstrap</a>
</section>
</div>
</div>
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
<!-- Contents
================================================== -->
<section id="contents">
<div class="page-header">
<h1>3. What's included</h1>
</div>
<p class="lead">Bootstrap comes equipped with HTML, CSS, and JS for all sorts of things, but they can be summarized with a handful of categories visible at the top of the <a href="http://getbootstrap.com">Bootstrap documentation</a>.</p>
<h2>Docs sections</h2>
<p>In addition to the getting started documentation you're reading now, the Bootstrap docs are broken into a few key pages.</p>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<h4><a href="http://twitter.github.com/bootstrap/css.html">Core CSS</a></h4>
<p>Global styles for the body, Normalize, links, grid system, tables, forms, buttons, icons, and more.</p>
<h4><a href="http://twitter.github.com/bootstrap/components.html">Components</a></h4>
<p>Basic styles for common interface components like tabs and pills, navbar, alerts, page headers, and more. Head here to see what kind of custom components Bootstrap has to offer beyond basic HTML elements.</p>
<h4><a href="http://twitter.github.com/bootstrap/javascript.html">JavaScript plugins</a></h4>
<p>Similar to Components, these JavaScript plugins are interactive components for things like tooltips, popovers, modals, and more.</p>
</section>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
<!-- HTML template
================================================== -->
<section id="html-template">
<div class="page-header">
<h1>4. Basic HTML template</h1>
</div>
<p class="lead">With a brief intro into the contents out of the way, we can focus on putting Bootstrap to use. To do that, we'll utilize a basic HTML template that includes everything we mentioned in the <a href="./getting-started.html#file-structure">File structure</a>.</p>
<p>Now, here's a look at a <strong>typical HTML file</strong>:</p>
{% highlight html linenos %}
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Hello, world!</h1>
<script src="http://code.jquery.com/jquery.js"></script>
</body>
</html>
{% endhighlight %}
<p>To make this <strong>a Bootstrapped template</strong>, just include the appropriate CSS and JS files:</p>
{% highlight html linenos %}
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<h1>Hello, world!</h1>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
{% endhighlight %}
<p><strong>And you're set!</strong> With those two files added, you can begin to develop any site or application with Bootstrap.</p>
<hr>
<h4>Responsive features in IE8</h4>
<p>Internet Explorer 8 lacks support for media queries, the method by which we deliver responsive CSS to folks. To enable that, you need to include a third party tool (which we include in the project repository) called <a href="https://github.com/scottjehl/Respond">Respond.js</a>.</p>
<pre class="prettyprint linenums">
&lt;!--[if lt IE 9]&gt;
&lt;script src="/assets/js/respond/respond.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;
</pre>
</section>
<!-- Examples
================================================== -->
<section id="examples">
<div class="page-header">
<h1>5. Examples</h1>
</div>
<p class="lead">Move beyond the base template with a few example layouts. We encourage folks to iterate on these examples and not simply use them as an end result.</p>
<div class="row bs-docs-examples">
<div class="span4">
<a class="thumbnail" href="/examples/starter-template/">
<img src="/assets/img/examples/bootstrap-example-starter.png" alt="">
</a>
<h4>Starter template</h4>
<p>A barebones HTML document with all the Bootstrap CSS and JavaScript included.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/jumbotron/">
<img src="/assets/img/examples/bootstrap-example-marketing.png" alt="">
</a>
<h4>Basic marketing site</h4>
<p>Featuring a hero unit for a primary message and three supporting elements.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/jumbotron-narrow/">
<img src="/assets/img/examples/bootstrap-example-jumbotron-narrow.png" alt="">
</a>
<h4>Narrow marketing</h4>
<p>Slim, lightweight marketing template for small projects or teams.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/justified-nav/">
<img src="/assets/img/examples/bootstrap-example-justified-nav.png" alt="">
</a>
<h4>Justified nav</h4>
<p>Marketing page with equal-width navigation links in a modified navbar.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/signin/">
<img src="/assets/img/examples/bootstrap-example-signin.png" alt="">
</a>
<h4>Sign in</h4>
<p>Barebones sign in form with custom, larger form controls and a flexible layout.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/sticky-footer/">
<img src="/assets/img/examples/bootstrap-example-sticky-footer.png" alt="">
</a>
<h4>Sticky footer</h4>
<p>Pin a fixed-height footer to the bottom of the user's viewport.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/sticky-footer-navbar/">
<img src="/assets/img/examples/bootstrap-example-sticky-footer-navbar.png" alt="">
</a>
<h4>Sticky footer w/ navbar</h4>
<p>Add a fixed navbar to the default sticky footer template.</p>
</div>
<div class="span4">
<a class="thumbnail" href="/examples/carousel/">
<img src="/assets/img/examples/bootstrap-example-carousel.png" alt="">
</a>
<h4>Carousel jumbotron</h4>
<p>An interactive riff on the basic marketing site featuring a prominent carousel.</p>
</div>
</div>
</section>
<!-- Next
================================================== -->
<section id="what-next">
<div class="page-header">
<h1>What next?</h1>
</div>
<p class="lead">Head to the docs for information, examples, and code snippets, or take the next leap and customize Bootstrap for any upcoming project.</p>
<a class="btn btn-large btn-primary" href="./css.html" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Visit docs']);">Visit the Bootstrap docs</a>
<a class="btn btn-large" href="./customize.html" style="margin-left: 5px;" onclick="_gaq.push(['_trackEvent', 'Getting started', 'Next steps', 'Customize']);">Customize Bootstrap</a>
</section>
</div><!-- /span9 -->
</div><!-- row -->
</div><!-- /.container -->

View File

@ -1,84 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active">
<a href="./index.html">Home</a>
</li>
<li class="">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="">
<a href="./components.html">Components</a>
</li>
<li class="">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
---
layout: default
title: Bootstrap
---
<div class="bs-docs-jumbotron masthead">
<div class="container">
<h1>Bootstrap</h1>
<p class="lead">Sleek, intuitive, and powerful mobile-first front-end framework for faster and easier web development.</p>
<p>
<a href="assets/bootstrap.zip" class="btn btn-large" >Download Bootstrap</a>
<a href="assets/bootstrap.zip" class="btn btn-large" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Download', 'Download 3.0.0']);">Download Bootstrap</a>
</p>
<ul class="masthead-links">
<li>
<a href="http://github.com/twitter/bootstrap" >GitHub project</a>
<a href="http://github.com/twitter/bootstrap" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'GitHub project']);">GitHub project</a>
</li>
<li>
<a href="./getting-started.html#examples" >Examples</a>
<a href="./getting-started.html#examples" onclick="_gaq.push(['_trackEvent', 'Jumbotron actions', 'Jumbotron links', 'Examples']);">Examples</a>
</li>
<li>Version 3.0.0</li>
</ul>
@ -138,71 +75,3 @@
</div>
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
</body>
</html>

View File

@ -1,70 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Javascript · Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!-- Documentation extras -->
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar">
<!-- Navbar
================================================== -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="./index.html">Bootstrap</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="">
<a href="./index.html">Home</a>
</li>
<li class="">
<a href="./getting-started.html">Get started</a>
</li>
<li class="">
<a href="./css.html">CSS</a>
</li>
<li class="">
<a href="./components.html">Components</a>
</li>
<li class="active">
<a href="./javascript.html">JavaScript</a>
</li>
<li class="">
<a href="./customize.html">Customize</a>
</li>
</ul>
</div>
</div>
</div>
---
layout: default
title: JavaScript plugins
---
<!-- Subhead
================================================== -->
@ -115,38 +52,47 @@
<p>You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first class API and should be your first consideration when using a plugin.</p>
<p>That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
<pre class="prettyprint linenums">$('body').off('.data-api')</pre>
{% highlight js linenos %}
$('body').off('.data-api')
{% endhighlight %}
<p>Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:</p>
<pre class="prettyprint linenums">$('body').off('.alert.data-api')</pre>
{% highlight js linenos %}
$('body').off('.alert.data-api')
{% endhighlight %}
<h3>Programmatic API</h3>
<p>We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.</p>
<pre class="prettyprint linenums">$(".btn.danger").button("toggle").addClass("fat")</pre>
{% highlight js linenos %}
$(".btn.danger").button("toggle").addClass("fat")
{% endhighlight %}
<p>All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):</p>
<pre class="prettyprint linenums">
$("#myModal").modal() // initialized with defaults
{% highlight js linenos %}
$("#myModal").modal() // initialized with defaults
$("#myModal").modal({ keyboard: false }) // initialized with no keyboard
$("#myModal").modal('show') // initializes and invokes show immediately</p>
</pre>
{% endhighlight %}
<p>Each plugin also exposes its raw constructor on a `Constructor` property: <code>$.fn.popover.Constructor</code>. If you'd like to get a particular plugin instance, retrieve it directly from an element: <code>$('[rel=popover]').data('popover')</code>.</p>
<h3>No conflict</h3>
<p>Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call <code>.noConflict</code> on the plugin you wish to revert the value of.</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the bootstrap functionality
</pre>
{% endhighlight %}
<h3>Events</h3>
<p>Bootstrap provides custom events for most plugin's unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is trigger on the completion of an action.</p>
<p>All infinitive events provide <code>preventDefault</code> functionality. This provides the ability to stop the execution of an action before it starts.</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myModal').on('show', function (e) {
if (!data) return e.preventDefault() // stops modal from being shown
})
</pre>
{% endhighlight %}
</section>
@ -168,6 +114,7 @@ $('#myModal').on('show', function (e) {
<li>Sliding carousel panes</li>
</ul>
<!-- Ideas: include docs for .fade.in, .slide.in, etc -->
</section>
@ -186,7 +133,6 @@ $('#myModal').on('show', function (e) {
<h3>Static example</h3>
<p>A rendered modal with header, body, and set of actions in the footer.</p>
<div class="bs-docs-example bs-docs-example-modal">
<div class="modal">
<div class="modal-dialog">
<div class="modal-content">
@ -204,29 +150,26 @@ $('#myModal').on('show', function (e) {
</div><!-- /.modal-content -->
</div><!-- /.modal-dalog -->
</div><!-- /.modal -->
</div>
<pre class="prettyprint linenums">
&lt;div class="modal fade"&gt;
&lt;div class="modal-dialog"&gt;
&lt;div class="modal-content"&gt;
&lt;div class="modal-header"&gt;
&lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
&lt;h4 class="modal-title"&gt;Modal title&lt;/h4&gt;
&lt;/div&gt;
&lt;div class="modal-body"&gt;
&lt;p&gt;One fine body&hellip;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="modal-footer"&gt;
&lt;a href="#" class="btn"&gt;Close&lt;/a&gt;
&lt;a href="#" class="btn btn-primary"&gt;Save changes&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dalog -->
</div><!-- /.modal -->
{% endhighlight %}
<h3>Live demo</h3>
<p>Toggle a modal via JavaScript by clicking the button below. It will slide down and fade in from the top of the page.</p>
@ -270,43 +213,44 @@ $('#myModal').on('show', function (e) {
<div class="bs-docs-example" style="padding-bottom: 24px;">
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large">Launch demo modal</a>
</div>
<pre class="prettyprint linenums">
&lt!-- Button to trigger modal --&gt;
&lt;a href="#myModal" role="button" class="btn" data-toggle="modal"&gt;Launch demo modal&lt;/a&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="modal">
<!-- Button trigger modal -->
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large">Launch demo modal</a>
&lt!-- Modal --&gt;
&lt;div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
&lt;div class="modal-dialog"&gt;
&lt;div class="modal-content"&gt;
&lt;div class="modal-header"&gt;
&lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
&lt;h4 class="modal-title"&gt;Modal title&lt;/h4&gt;
&lt;/div&gt;
&lt;div class="modal-body"&gt;
<!-- Modal -->
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
...
&lt;/div&gt;
&lt;div class="modal-footer"&gt;
&lt;a href="#" class="btn"&gt;Close&lt;/a&gt;
&lt;a href="#" class="btn btn-primary"&gt;Save changes&lt;/a&gt;
&lt;/div&gt;
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dalog -->
</div><!-- /.modal -->
{% endhighlight %}
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<h2>Usage</h2>
<h3>Via data attributes</h3>
<p>Activate a modal without writing JavaScript. Set <code>data-toggle="modal"</code> on a controller element, like a button, along with a <code>data-target="#foo"</code> or <code>href="#foo"</code> to target a specific modal to toggle.</p>
<pre class="prettyprint linenums">&lt;button type="button" data-toggle="modal" data-target="#myModal"&gt;Launch modal&lt;/button&gt;</pre>
{% highlight html linenos %}
<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>
{% endhighlight %}
<h3>Via JavaScript</h3>
<p>Call a modal with id <code>myModal</code> with a single line of JavaScript:</p>
<pre class="prettyprint linenums">$('#myModal').modal(options)</pre>
{% highlight js linenos %}$('#myModal').modal(options){% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-backdrop=""</code>.</p>
@ -343,28 +287,35 @@ $('#myModal').on('show', function (e) {
<td>path</td>
<td>false</td>
<td><p>If a remote url is provided, content will be loaded via jQuery's <code>load</code> method and injected into the <code>.modal-body</code>. If you're using the data api, you may alternatively use the <code>href</code> tag to specify the remote source. An example of this is shown below:</p>
<pre class="prettyprint linenums"><code>&lt;a data-toggle="modal" href="remote.html" data-target="#modal"&gt;click me&lt;/a&gt;</code></pre></td>
{% highlight html linenos %}
<a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>
{% endhighlight %}
</tr>
</tbody>
</table>
<h3>Methods</h3>
<h4>.modal(options)</h4>
<p>Activates your content as a modal. Accepts an optional options <code>object</code>.</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myModal').modal({
keyboard: false
})
</pre>
{% endhighlight %}
<h4>.modal('toggle')</h4>
<p>Manually toggles a modal.</p>
<pre class="prettyprint linenums">$('#myModal').modal('toggle')</pre>
{% highlight js linenos %}$('#myModal').modal('toggle'){% endhighlight %}
<h4>.modal('show')</h4>
<p>Manually opens a modal.</p>
<pre class="prettyprint linenums">$('#myModal').modal('show')</pre>
{% highlight js linenos %}$('#myModal').modal('show'){% endhighlight %}
<h4>.modal('hide')</h4>
<p>Manually hides a modal.</p>
<pre class="prettyprint linenums">$('#myModal').modal('hide')</pre>
{% highlight js linenos %}$('#myModal').modal('hide'){% endhighlight %}
<h3>Events</h3>
<p>Bootstrap's modal class exposes a few events for hooking into modal functionality.</p>
<table class="table table-bordered table-striped">
@ -393,11 +344,11 @@ $('#myModal').modal({
</tr>
</tbody>
</table>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myModal').on('hidden', function () {
// do something…
})
</pre>
{% endhighlight %}
</section>
@ -456,7 +407,7 @@ $('#myModal').on('hidden', function () {
</div>
</div>
</div> <!-- /navbar-example -->
</div>
</div> <!-- /example -->
<h3>Within tabs</h3>
<div class="bs-docs-example">
@ -493,7 +444,7 @@ $('#myModal').on('hidden', function () {
</ul>
</li>
</ul> <!-- /tabs -->
</div>
</div> <!-- /example -->
<hr class="bs-docs-separator">
@ -503,30 +454,31 @@ $('#myModal').on('hidden', function () {
<h3>Via data attributes</h3>
<p>Add <code>data-toggle="dropdown"</code> to a link or button to toggle a dropdown.</p>
<pre class="prettyprint linenums">
&lt;div class="dropdown"&gt;
&lt;a class="dropdown-toggle" data-toggle="dropdown" href="#"&gt;Dropdown trigger&lt;/a&gt;
&lt;ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"&gt;
{% highlight html linenos %}
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
...
&lt;/ul&gt;
&lt;/div&gt;
</pre>
</ul>
</div>
{% endhighlight %}
<p>To keep URLs intact, use the <code>data-target</code> attribute instead of <code>href="#"</code>.</p>
<pre class="prettyprint linenums">
&lt;div class="dropdown"&gt;
&lt;a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html"&gt;
Dropdown
&lt;b class="caret"&gt;&lt;/b&gt;
&lt;/a&gt;
&lt;ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"&gt;
{% highlight html linenos %}
<div class="dropdown">
<a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
...
&lt;/ul&gt;
&lt;/div&gt;
</pre>
</ul>
</div>
{% endhighlight %}
<h3>Via JavaScript</h3>
<p>Call the dropdowns via JavaScript:</p>
<pre class="prettyprint linenums">$('.dropdown-toggle').dropdown()</pre>
{% highlight js linenos %}
$('.dropdown-toggle').dropdown()
{% endhighlight %}
<h3>Options</h3>
<p><em>None</em></p>
@ -583,7 +535,7 @@ $('#myModal').on('hidden', function () {
<p>Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.
</p>
</div>
</div>
</div><!-- /example -->
<hr class="bs-docs-separator">
@ -593,11 +545,17 @@ $('#myModal').on('hidden', function () {
<h3>Via data attributes</h3>
<p>To easily add scrollspy behavior to your topbar navigation, just add <code>data-spy="scroll"</code> to the element you want to spy on (most typically this would be the body) and <code>data-target=".navbar"</code> to select which nav to use. You'll want to use scrollspy with a <code>.nav</code> component.</p>
<pre class="prettyprint linenums">&lt;body data-spy="scroll" data-target=".navbar"&gt;...&lt;/body&gt;</pre>
{% highlight html linenos %}
<body data-spy="scroll" data-target=".navbar">
...
</body>
{% endhighlight %}
<h3>Via JavaScript</h3>
<p>Call the scrollspy via JavaScript:</p>
<pre class="prettyprint linenums">$('#navbar').scrollspy()</pre>
{% highlight js linenos %}
$('#navbar').scrollspy()
{% endhighlight %}
<div class="alert alert-info">
<strong>Heads up!</strong>
@ -607,11 +565,12 @@ $('#myModal').on('hidden', function () {
<h3>Methods</h3>
<h4>.scrollspy('refresh')</h4>
<p>When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
});
</pre>
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-offset=""</code>.</p>
@ -689,7 +648,7 @@ $('[data-spy="scroll"]').each(function () {
<p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p>
</div>
</div>
</div>
</div><!-- /example -->
<hr class="bs-docs-separator">
@ -697,28 +656,32 @@ $('[data-spy="scroll"]').each(function () {
<h2>Usage</h2>
<p>Enable tabbable tabs via JavaScript (each tab needs to be activated individually):</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})</pre>
})
{% endhighlight %}
<p>You can activate individual tabs in several ways:</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myTab a[href="#profile"]').tab('show'); // Select tab by name
$('#myTab a:first').tab('show'); // Select first tab
$('#myTab a:last').tab('show'); // Select last tab
$('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed)
</pre>
{% endhighlight %}
<h3>Markup</h3>
<p>You can activate a tab or pill navigation without writing any JavaScript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the Bootstrap tab styling.</p>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-tabs"&gt;
&lt;li&gt;&lt;a href="#home" data-toggle="tab"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#profile" data-toggle="tab"&gt;Profile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#messages" data-toggle="tab"&gt;Messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#settings" data-toggle="tab"&gt;Settings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
{% highlight html linenos %}
<ul class="nav nav-tabs">
<li><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li>
</ul>
{% endhighlight %}
<p>To make tabs fade in, add <code>.fade</code> to each <code>.tab-pane</code>.</p>
<h3>Methods</h3>
@ -726,27 +689,27 @@ $('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed)
<p>
Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM.
</p>
<pre class="prettyprint linenums">
&lt;ul class="nav nav-tabs" id="myTab"&gt;
&lt;li class="active"&gt;&lt;a href="#home"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#profile"&gt;Profile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#messages"&gt;Messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#settings"&gt;Settings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
{% highlight html linenos %}
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li>
<li><a href="#settings">Settings</a></li>
</ul>
&lt;div class="tab-content"&gt;
&lt;div class="tab-pane active" id="home"&gt;...&lt;/div&gt;
&lt;div class="tab-pane" id="profile"&gt;...&lt;/div&gt;
&lt;div class="tab-pane" id="messages"&gt;...&lt;/div&gt;
&lt;div class="tab-pane" id="settings"&gt;...&lt;/div&gt;
&lt;/div&gt;
<div class="tab-content">
<div class="tab-pane active" id="home">...</div>
<div class="tab-pane" id="profile">...</div>
<div class="tab-pane" id="messages">...</div>
<div class="tab-pane" id="settings">...</div>
</div>
&lt;script&gt;
<script>
$(function () {
$('#myTab a:last').tab('show');
})
&lt;/script&gt;
</pre>
</script>
{% endhighlight %}
<h3>Events</h3>
<table class="table table-bordered table-striped">
@ -767,12 +730,12 @@ $('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed)
</tr>
</tbody>
</table>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('a[data-toggle="tab"]').on('shown', function (e) {
e.target // activated tab
e.relatedTarget // previous tab
})
</pre>
{% endhighlight %}
</section>
@ -790,7 +753,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<div class="bs-docs-example tooltip-demo">
<p class="muted" style="margin-bottom: 0;">Tight pants next level keffiyeh <a href="#" data-toggle="tooltip" title="Default tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" data-toggle="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" data-toggle="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" data-toggle="tooltip" title="The last tip!">twitter handle</a> freegan cred raw denim single-origin coffee viral.
</p>
</div>
</div><!-- /example -->
<h3>Four directions</h3>
<div class="bs-docs-example tooltip-demo">
@ -800,7 +763,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<li><a href="#" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</a></li>
<li><a href="#" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</a></li>
</ul>
</div>
</div><!-- /example -->
<h3>Tooltips in input groups</h3>
@ -811,7 +774,9 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h2>Usage</h2>
<p>Trigger the tooltip via JavaScript:</p>
<pre class="prettyprint linenums">$('#example').tooltip(options)</pre>
{% highlight js linenos %}
$('#example').tooltip(options)
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-animation=""</code>.</p>
@ -887,23 +852,30 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
</div>
<h3>Markup</h3>
<pre class="prettyprint linenums">&lt;a href="#" data-toggle="tooltip" title="first tooltip"&gt;hover over me&lt;/a&gt;</pre>
{% highlight html linenos %}
<a href="#" data-toggle="tooltip" title="first tooltip">Hover over me</a>
{% endhighlight %}
<h3>Methods</h3>
<h4>$().tooltip(options)</h4>
<p>Attaches a tooltip handler to an element collection.</p>
<h4>.tooltip('show')</h4>
<p>Reveals an element's tooltip.</p>
<pre class="prettyprint linenums">$('#element').tooltip('show')</pre>
{% highlight js linenos %}$('#element').tooltip('show'){% endhighlight %}
<h4>.tooltip('hide')</h4>
<p>Hides an element's tooltip.</p>
<pre class="prettyprint linenums">$('#element').tooltip('hide')</pre>
{% highlight js linenos %}$('#element').tooltip('hide'){% endhighlight %}
<h4>.tooltip('toggle')</h4>
<p>Toggles an element's tooltip.</p>
<pre class="prettyprint linenums">$('#element').tooltip('toggle')</pre>
{% highlight js linenos %}$('#element').tooltip('toggle'){% endhighlight %}
<h4>.tooltip('destroy')</h4>
<p>Hides and destroys an element's tooltip.</p>
<pre class="prettyprint linenums">$('#element').tooltip('destroy')</pre>
{% highlight js linenos %}$('#element').tooltip('destroy'){% endhighlight %}
</section>
@ -970,7 +942,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<li><a href="#" class="btn" data-toggle="popover" data-placement="bottom" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." title="Popover on bottom">Popover on bottom</a></li>
<li><a href="#" class="btn" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." title="Popover on left">Popover on left</a></li>
</ul>
</div>
</div><!-- /example -->
<hr class="bs-docs-separator">
@ -978,7 +950,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h2>Usage</h2>
<p>Enable popovers via JavaScript:</p>
<pre class="prettyprint linenums">$('#example').popover(options)</pre>
{% highlight js linenos %}$('#example').popover(options){% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-animation=""</code>.</p>
@ -1065,18 +1037,22 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h3>Methods</h3>
<h4>$().popover(options)</h4>
<p>Initializes popovers for an element collection.</p>
<h4>.popover('show')</h4>
<p>Reveals an elements popover.</p>
<pre class="prettyprint linenums">$('#element').popover('show')</pre>
{% highlight js linenos %}$('#element').popover('show'){% endhighlight %}
<h4>.popover('hide')</h4>
<p>Hides an elements popover.</p>
<pre class="prettyprint linenums">$('#element').popover('hide')</pre>
{% highlight js linenos %}$('#element').popover('hide'){% endhighlight %}
<h4>.popover('toggle')</h4>
<p>Toggles an elements popover.</p>
<pre class="prettyprint linenums">$('#element').popover('toggle')</pre>
{% highlight js linenos %}$('#element').popover('toggle'){% endhighlight %}
<h4>.popover('destroy')</h4>
<p>Hides and destroys an element's popover.</p>
<pre class="prettyprint linenums">$('#element').popover('destroy')</pre>
{% highlight js linenos %}$('#element').popover('destroy'){% endhighlight %}
</section>
@ -1096,7 +1072,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
</div>
</div><!-- /example -->
<div class="bs-docs-example">
<div class="alert alert-block alert-error fade in">
@ -1107,7 +1083,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<a class="btn btn-danger" href="#">Take this action</a> <a class="btn" href="#">Or do this</a>
</p>
</div>
</div>
</div><!-- /example -->
<hr class="bs-docs-separator">
@ -1115,18 +1091,20 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<h2>Usage</h2>
<p>Enable dismissal of an alert via JavaScript:</p>
<pre class="prettyprint linenums">$(".alert").alert()</pre>
{% highlight js linenos %}$(".alert").alert(){% endhighlight %}
<h3>Markup</h3>
<p>Just add <code>data-dismiss="alert"</code> to your close button to automatically give an alert close functionality.</p>
<pre class="prettyprint linenums">&lt;a class="close" data-dismiss="alert" href="#"&gt;&amp;times;&lt;/a&gt;</pre>
{% highlight html linenos %}<a class="close" data-dismiss="alert" href="#">&times;</a>{% endhighlight %}
<h3>Methods</h3>
<h4>$().alert()</h4>
<p>Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the <code>.fade</code> and <code>.in</code> class already applied to them.</p>
<h4>.alert('close')</h4>
<p>Closes an alert.</p>
<pre class="prettyprint linenums">$(".alert").alert('close')</pre>
{% highlight js linenos %}$(".alert").alert('close'){% endhighlight %}
<h3>Events</h3>
@ -1149,11 +1127,11 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
</tr>
</tbody>
</table>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#my-alert').bind('closed', function () {
// do something…
})
</pre>
{% endhighlight %}
</section>
@ -1171,18 +1149,24 @@ $('#my-alert').bind('closed', function () {
<h4>Stateful</h4>
<p>Add <code>data-loading-text="Loading..."</code> to use a loading state on a button.</p>
<div class="bs-docs-example" style="padding-bottom: 24px;">
<button type="button" id="fat-btn" data-loading-text="loading..." class="btn btn-primary">
<button type="button" id="fat-btn" data-loading-text="Loading..." class="btn btn-primary">
Loading state
</button>
</div>
<pre class="prettyprint linenums">&lt;button type="button" class="btn btn-primary" data-loading-text="Loading..."&gt;Loading state&lt;/button&gt;</pre>
</div><!-- /example -->
{% highlight html linenos %}
<button type="button" id="fat-btn" data-loading-text="Loading..." class="btn btn-primary">
Loading state
</button>
{% endhighlight %}
<h4>Single toggle</h4>
<p>Add <code>data-toggle="button"</code> to activate toggling on a single button.</p>
<div class="bs-docs-example" style="padding-bottom: 24px;">
<button type="button" class="btn btn-primary" data-toggle="button">Single Toggle</button>
</div>
<pre class="prettyprint linenums">&lt;button type="button" class="btn btn-primary" data-toggle="button"&gt;Single Toggle&lt;/button&gt;</pre>
<button type="button" class="btn btn-primary" data-toggle="button">Single toggle</button>
</div><!-- /example -->
{% highlight html linenos %}
<button type="button" class="btn btn-primary" data-toggle="button">Single toggle</button>
{% endhighlight %}
<h4>Checkbox</h4>
<p>Add <code>data-toggle="buttons-checkbox"</code> for checkbox style toggling on btn-group.</p>
@ -1192,14 +1176,14 @@ $('#my-alert').bind('closed', function () {
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group" data-toggle="buttons-checkbox"&gt;
&lt;button type="button" class="btn btn-primary"&gt;Left&lt;/button&gt;
&lt;button type="button" class="btn btn-primary"&gt;Middle&lt;/button&gt;
&lt;button type="button" class="btn btn-primary"&gt;Right&lt;/button&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div class="btn-group" data-toggle="buttons-checkbox">
<button type="button" class="btn btn-primary">Left</button>
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>
{% endhighlight %}
<h4>Radio</h4>
<p>Add <code>data-toggle="buttons-radio"</code> for radio style toggling on btn-group.</p>
@ -1209,14 +1193,14 @@ $('#my-alert').bind('closed', function () {
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="btn-group" data-toggle="buttons-radio"&gt;
&lt;button type="button" class="btn btn-primary"&gt;Left&lt;/button&gt;
&lt;button type="button" class="btn btn-primary"&gt;Middle&lt;/button&gt;
&lt;button type="button" class="btn btn-primary"&gt;Right&lt;/button&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn btn-primary">Left</button>
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>
{% endhighlight %}
<hr class="bs-docs-separator">
@ -1224,7 +1208,9 @@ $('#my-alert').bind('closed', function () {
<h2>Usage</h2>
<p>Enable buttons via JavaScript:</p>
<pre class="prettyprint linenums">$('.nav-tabs').button()</pre>
{% highlight js linenos %}
$('.nav-tabs').button()
{% endhighlight %}
<h3>Markup</h3>
<p>Data attributes are integral to the button plugin. Check out the example code below for the various markup types.</p>
@ -1233,30 +1219,40 @@ $('#my-alert').bind('closed', function () {
<p><em>None</em></p>
<h3>Methods</h3>
<h4>$().button('toggle')</h4>
<p>Toggles push state. Gives the button the appearance that it has been activated.</p>
<div class="alert alert-info">
<strong>Heads up!</strong>
You can enable auto toggling of a button by using the <code>data-toggle</code> attribute.
</div>
<pre class="prettyprint linenums">&lt;button type="button" class="btn" data-toggle="button" &gt;&lt;/button&gt;</pre>
{% highlight html linenos %}
<button type="button" class="btn" data-toggle="button">...</button>
{% endhighlight %}
<h4>$().button('loading')</h4>
<p>Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute <code>data-loading-text</code>.
</p>
<pre class="prettyprint linenums">&lt;button type="button" class="btn" data-loading-text="loading stuff..." &gt;...&lt;/button&gt;</pre>
{% highlight html linenos %}
<button type="button" class="btn" data-loading-text="loading stuff...">...</button>
{% endhighlight %}
<div class="alert alert-info">
<strong>Heads up!</strong>
<a href="https://github.com/twitter/bootstrap/issues/793">Firefox persists the disabled state across page loads</a>. A workaround for this is to use <code>autocomplete="off"</code>.
</div>
<h4>$().button('reset')</h4>
<p>Resets button state - swaps text to original text.</p>
<h4>$().button(string)</h4>
<p>Resets button state - swaps text to any data defined text state.</p>
<pre class="prettyprint linenums">&lt;button type="button" class="btn" data-complete-text="finished!" &gt;...&lt;/button&gt;
&lt;script&gt;
{% highlight html linenos %}
<button type="button" class="btn" data-complete-text="finished!" >...</button>
<script>
$('.btn').button('complete')
&lt;/script&gt;
</pre>
</script>
{% endhighlight %}
</section>
@ -1314,44 +1310,56 @@ $('#my-alert').bind('closed', function () {
</div>
</div>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div class="accordion" id="accordion2"&gt;
&lt;div class="accordion-group"&gt;
&lt;div class="accordion-heading"&gt;
&lt;a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne"&gt;
</div><!-- /example -->
{% highlight html linenos %}
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
Collapsible Group Item #1
&lt;/a&gt;
&lt;/div&gt;
&lt;div id="collapseOne" class="accordion-body collapse in"&gt;
&lt;div class="accordion-inner"&gt;
Anim pariatur cliche...
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="accordion-group"&gt;
&lt;div class="accordion-heading"&gt;
&lt;a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo"&gt;
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
...
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
Collapsible Group Item #2
&lt;/a&gt;
&lt;/div&gt;
&lt;div id="collapseTwo" class="accordion-body collapse"&gt;
&lt;div class="accordion-inner"&gt;
Anim pariatur cliche...
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
...
</pre>
<p>You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.</p>
<pre class="prettyprint linenums">
&lt;button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo"&gt;
simple collapsible
&lt;/button&gt;
</a>
</div>
<div id="collapseTwo" class="accordion-body collapse">
<div class="accordion-inner">
...
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
Collapsible Group Item #3
</a>
</div>
<div id="collapseThree" class="accordion-body collapse">
<div class="accordion-inner">
...
</div>
</div>
</div>
</div>
{% endhighlight %}
&lt;div id="demo" class="collapse in"&gt;&lt;/div&gt;
</pre>
<p>You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.</p>
{% highlight html linenos %}
<button type="button" class="btn btn-danger" data-toggle="collapse" data-target="#demo">
simple collapsible
</button>
<div id="demo" class="collapse in">...</div>
{% endhighlight %}
<hr class="bs-docs-separator">
@ -1365,7 +1373,9 @@ $('#my-alert').bind('closed', function () {
<h3>Via JavaScript</h3>
<p>Enable manually with:</p>
<pre class="prettyprint linenums">$(".collapse").collapse()</pre>
{% highlight js linenos %}
$(".collapse").collapse()
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-parent=""</code>.</p>
@ -1396,17 +1406,21 @@ $('#my-alert').bind('closed', function () {
<h3>Methods</h3>
<h4>.collapse(options)</h4>
<p>Activates your content as a collapsible element. Accepts an optional options <code>object</code>.
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myCollapsible').collapse({
toggle: false
})
</pre>
{% endhighlight %}
<h4>.collapse('toggle')</h4>
<p>Toggles a collapsible element to shown or hidden.</p>
<h4>.collapse('show')</h4>
<p>Shows a collapsible element.</p>
<h4>.collapse('hide')</h4>
<p>Hides a collapsible element.</p>
@ -1440,10 +1454,11 @@ $('#myCollapsible').collapse({
</tr>
</tbody>
</table>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('#myCollapsible').on('hidden', function () {
// do something…
})</pre>
})
{% endhighlight %}
</section>
@ -1494,25 +1509,36 @@ $('#myCollapsible').on('hidden', function () {
<span class="control">&rsaquo;</span>
</a>
</div>
</div>
<pre class="prettyprint linenums">
&lt;div id="myCarousel" class="carousel slide"&gt;
&lt;ol class="carousel-indicators"&gt
&lt;li data-target="#myCarousel" data-slide-to="0" class="active"&gt&lt;/li&gt
&lt;li data-target="#myCarousel" data-slide-to="1"&gt&lt;/li&gt
&lt;li data-target="#myCarousel" data-slide-to="2"&gt&lt;/li&gt
&lt;/ol&gt
&lt;!-- Carousel items --&gt;
&lt;div class="carousel-inner"&gt;
&lt;div class="active item"&gt;&lt;/div&gt;
&lt;div class="item"&gt;&lt;/div&gt;
&lt;div class="item"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;!-- Carousel nav --&gt;
&lt;a class="carousel-control left" href="#myCarousel" data-slide="prev"&gt;&amp;lsaquo;&lt;/a&gt;
&lt;a class="carousel-control right" href="#myCarousel" data-slide="next"&gt;&amp;rsaquo;&lt;/a&gt;
&lt;/div&gt;
</pre>
</div><!-- /example -->
{% highlight html linenos %}
<div id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="..." alt="">
<div class="carousel-caption">
...
</div>
</div>
...
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="control">&lsaquo;</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="control">&rsaquo;</span>
</a>
</div>
{% endhighlight %}
<div class="alert alert-warning">
<strong>Heads up!</strong>
@ -1530,7 +1556,9 @@ $('#myCollapsible').on('hidden', function () {
<h3>Via JavaScript</h3>
<p>Call carousel manually with:</p>
<pre class="prettyprint linenums">$('.carousel').carousel()</pre>
{% highlight js linenos %}
$('.carousel').carousel()
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-interval=""</code>.</p>
@ -1560,21 +1588,27 @@ $('#myCollapsible').on('hidden', function () {
</table>
<h3>Methods</h3>
<h4>.carousel(options)</h4>
<p>Initializes the carousel with an optional options <code>object</code> and starts cycling through items.</p>
<pre class="prettyprint linenums">
{% highlight html linenos %}
$('.carousel').carousel({
interval: 2000
})
</pre>
{% endhighlight %}
<h4>.carousel('cycle')</h4>
<p>Cycles through the carousel items from left to right.</p>
<h4>.carousel('pause')</h4>
<p>Stops the carousel from cycling through items.</p>
<h4>.carousel(number)</h4>
<p>Cycles the carousel to a particular frame (0 based, similar to an array).</p>
<h4>.carousel('prev')</h4>
<p>Cycles to the previous item.</p>
<h4>.carousel('next')</h4>
<p>Cycles to the next item.</p>
@ -1614,8 +1648,11 @@ $('.carousel').carousel({
<p>A basic, easily extended plugin for quickly creating elegant typeaheads with any form text input.</p>
<div class="bs-docs-example" style="background-color: #f5f5f5;">
<input type="text" class="span3" style="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source='["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Dakota","North Carolina","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"]'>
</div>
<pre class="prettyprint linenums">&lt;input type="text" data-provide="typeahead"&gt;</pre>
</div><!-- /example -->
{% highlight html linenos %}
<input type="text" data-provide="typeahead">
{% endhighlight %}
<p>You'll want to set <code>autocomplete="off"</code> to prevent default browser menus from appearing over the Bootstrap typeahead dropdown.</p>
<hr class="bs-docs-separator">
@ -1628,7 +1665,9 @@ $('.carousel').carousel({
<h3>Via JavaScript</h3>
<p>Call the typeahead manually with:</p>
<pre class="prettyprint linenums">$('.typeahead').typeahead()</pre>
{% highlight js linenos %}
$('.typeahead').typeahead()
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-source=""</code>.</p>
@ -1711,7 +1750,9 @@ $('.carousel').carousel({
<h3>Via data attributes</h3>
<p>To easily add affix behavior to any element, just add <code>data-spy="affix"</code> to the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.</p>
<pre class="prettyprint linenums">&lt;div data-spy="affix" data-offset-top="200"&gt;...&lt;/div&gt;</pre>
{% highlight html linenos %}
<div data-spy="affix" data-offset-top="200">...</div>
{% endhighlight %}
<div class="alert alert-info">
<strong>Heads up!</strong>
@ -1720,16 +1761,19 @@ $('.carousel').carousel({
<h3>Via JavaScript</h3>
<p>Call the affix plugin via JavaScript:</p>
<pre class="prettyprint linenums">$('#navbar').affix()</pre>
{% highlight js linenos %}
$('#navbar').affix()
{% endhighlight %}
<h3>Methods</h3>
<h4>.affix('refresh')</h4>
<p>When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:</p>
<pre class="prettyprint linenums">
{% highlight js linenos %}
$('[data-spy="affix"]').each(function () {
$(this).affix('refresh')
});
</pre>
{% endhighlight %}
<h3>Options</h3>
<p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-offset-top="200"</code>.</p>
@ -1755,75 +1799,7 @@ $('[data-spy="affix"]').each(function () {
</div>
</div>
</div><!-- /span9 -->
</div><!-- row -->
</div>
<!-- Footer
================================================== -->
<footer class="footer">
<div class="container">
<div class="bs-docs-social">
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=twitter&repo=bootstrap&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li class="follow-btn">
<a href="https://twitter.com/twbootstrap" class="twitter-follow-button" data-link-color="#0069D6" data-show-count="true">Follow @twbootstrap</a>
</li>
<li class="tweet-btn">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://twitter.github.com/bootstrap/" data-count="horizontal" data-via="twbootstrap" data-related="mdo:Creator of Twitter Bootstrap">Tweet</a>
</li>
</ul>
</div>
<p>Designed and built with all the love in the world by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>, documentation under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p><a href="http://glyphicons.com">Glyphicons Free</a> licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<ul class="footer-links">
<li><a href="http://blog.getbootstrap.com">Blog</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/issues?state=open">Issues</a></li>
<li class="muted">&middot;</li>
<li><a href="https://github.com/twitter/bootstrap/blob/master/CHANGELOG.md">Changelog</a></li>
</ul>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="assets/js/bootstrap-affix.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script src="assets/js/holder/holder.js"></script>
<script src="assets/js/google-code-prettify/prettify.js"></script>
<script src="assets/js/application.js"></script>
</body>
</html>
</div><!-- /.container -->

Some files were not shown because too many files have changed in this diff Show More