sass-twitter-bootstrap 0.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/{sass-twitter-bootstrap.rb → sass/twitter/bootstrap.rb} +1 -1
- data/lib/sass/twitter/bootstrap/rails.rb +1 -5
- data/lib/sass/twitter/bootstrap/rails/engine.rb +12 -0
- data/lib/sass/twitter/bootstrap/version.rb +1 -1
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap-alert.js +32 -28
- data/vendor/assets/javascripts/twitter/bootstrap-button.js +33 -29
- data/vendor/assets/javascripts/twitter/bootstrap-carousel.js +21 -33
- data/vendor/assets/javascripts/twitter/bootstrap-collapse.js +26 -47
- data/vendor/assets/javascripts/twitter/bootstrap-dropdown.js +10 -18
- data/vendor/assets/javascripts/twitter/bootstrap-modal.js +17 -25
- data/vendor/assets/javascripts/twitter/bootstrap-popover.js +10 -13
- data/vendor/assets/javascripts/twitter/bootstrap-scrollspy.js +18 -44
- data/vendor/assets/javascripts/twitter/bootstrap-tab.js +7 -12
- data/vendor/assets/javascripts/twitter/bootstrap-tooltip.js +35 -40
- data/vendor/assets/javascripts/twitter/bootstrap-transition.js +20 -30
- data/vendor/assets/javascripts/twitter/bootstrap-typeahead.js +15 -29
- data/vendor/assets/stylesheets/tests/buttons.html +139 -0
- data/vendor/assets/stylesheets/tests/css-tests.css +99 -1
- data/vendor/assets/stylesheets/tests/css-tests.html +519 -37
- data/vendor/assets/stylesheets/tests/forms-responsive.html +71 -0
- data/vendor/assets/stylesheets/tests/navbar-fixed-top.html +104 -0
- data/vendor/assets/stylesheets/tests/navbar-static-top.html +107 -0
- data/vendor/assets/stylesheets/tests/navbar.html +38 -39
- data/vendor/assets/stylesheets/twitter/_accordion.scss +0 -5
- data/vendor/assets/stylesheets/twitter/_alerts.scss +15 -3
- data/vendor/assets/stylesheets/twitter/_breadcrumbs.scss +0 -2
- data/vendor/assets/stylesheets/twitter/_button-groups.scss +32 -76
- data/vendor/assets/stylesheets/twitter/_buttons.scss +25 -33
- data/vendor/assets/stylesheets/twitter/_close.scss +1 -12
- data/vendor/assets/stylesheets/twitter/_code.scss +8 -8
- data/vendor/assets/stylesheets/twitter/_component-animations.scss +7 -9
- data/vendor/assets/stylesheets/twitter/_dropdowns.scss +45 -58
- data/vendor/assets/stylesheets/twitter/_forms.scss +146 -206
- data/vendor/assets/stylesheets/twitter/_grid.scss +5 -2
- data/vendor/assets/stylesheets/twitter/_hero-unit.scss +1 -3
- data/vendor/assets/stylesheets/twitter/_labels.scss +32 -0
- data/vendor/assets/stylesheets/twitter/_layouts.scss +2 -2
- data/vendor/assets/stylesheets/twitter/_mixins.scss +208 -273
- data/vendor/assets/stylesheets/twitter/_modals.scss +8 -14
- data/vendor/assets/stylesheets/twitter/_navbar.scss +73 -132
- data/vendor/assets/stylesheets/twitter/_navs.scss +43 -53
- data/vendor/assets/stylesheets/twitter/_pager.scss +0 -6
- data/vendor/assets/stylesheets/twitter/_pagination.scss +0 -1
- data/vendor/assets/stylesheets/twitter/_progress-bars.scss +6 -28
- data/vendor/assets/stylesheets/twitter/_reset.scss +4 -9
- data/vendor/assets/stylesheets/twitter/_scaffolding.scss +8 -4
- data/vendor/assets/stylesheets/twitter/_sprites.scss +7 -40
- data/vendor/assets/stylesheets/twitter/_tables.scss +33 -38
- data/vendor/assets/stylesheets/twitter/_thumbnails.scss +2 -14
- data/vendor/assets/stylesheets/twitter/_tooltip.scss +1 -1
- data/vendor/assets/stylesheets/twitter/_type.scss +14 -28
- data/vendor/assets/stylesheets/twitter/_variables.scss +19 -116
- data/vendor/assets/stylesheets/twitter/_wells.scss +0 -10
- data/vendor/assets/stylesheets/twitter/bootstrap.scss +7 -3
- data/vendor/assets/stylesheets/twitter/responsive.scss +301 -15
- metadata +25 -190
- data/.gitignore +0 -4
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -14
- data/LICENSE +0 -176
- data/Makefile +0 -94
- data/README.md +0 -217
- data/Rakefile +0 -52
- data/bootstrap-2.0.4.css +0 -4661
- data/bootstrap-2.0.4.min.css +0 -9
- data/bootstrap-responsive-2.0.4.css +0 -932
- data/bootstrap-responsive-2.0.4.min.css +0 -9
- data/docs/assets/css/bootstrap-responsive.css +0 -932
- data/docs/assets/css/bootstrap.css +0 -4661
- data/docs/assets/css/docs.css +0 -846
- data/docs/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
- data/docs/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
- data/docs/assets/ico/favicon.ico +0 -0
- data/docs/assets/img/bird.png +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-01.jpg +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-02.jpg +0 -0
- data/docs/assets/img/bootstrap-mdo-sfmoma-03.jpg +0 -0
- data/docs/assets/img/browsers.png +0 -0
- data/docs/assets/img/example-sites/fleetio.png +0 -0
- data/docs/assets/img/example-sites/jshint.png +0 -0
- data/docs/assets/img/example-sites/kippt.png +0 -0
- data/docs/assets/img/example-sites/soundready.png +0 -0
- data/docs/assets/img/examples/bootstrap-example-fluid.jpg +0 -0
- data/docs/assets/img/examples/bootstrap-example-hero.jpg +0 -0
- data/docs/assets/img/examples/bootstrap-example-starter.jpg +0 -0
- data/docs/assets/img/github-16px.png +0 -0
- data/docs/assets/img/glyphicons-halflings-white.png +0 -0
- data/docs/assets/img/glyphicons-halflings.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_009_magic.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_042_group.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_079_podium.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_082_roundabout.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_155_show_thumbnails.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_163_iphone.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_214_resize_small.png +0 -0
- data/docs/assets/img/glyphicons/glyphicons_266_book_open.png +0 -0
- data/docs/assets/img/grid-18px-masked.png +0 -0
- data/docs/assets/img/icon-css3.png +0 -0
- data/docs/assets/img/icon-github.png +0 -0
- data/docs/assets/img/icon-html5.png +0 -0
- data/docs/assets/img/icon-twitter.png +0 -0
- data/docs/assets/img/less-logo-large.png +0 -0
- data/docs/assets/img/less-small.png +0 -0
- data/docs/assets/img/responsive-illustrations.png +0 -0
- data/docs/assets/js/README.md +0 -106
- data/docs/assets/js/application.js +0 -184
- data/docs/assets/js/bootstrap-alert.js +0 -90
- data/docs/assets/js/bootstrap-button.js +0 -96
- data/docs/assets/js/bootstrap-carousel.js +0 -169
- data/docs/assets/js/bootstrap-collapse.js +0 -157
- data/docs/assets/js/bootstrap-dropdown.js +0 -100
- data/docs/assets/js/bootstrap-modal.js +0 -218
- data/docs/assets/js/bootstrap-popover.js +0 -98
- data/docs/assets/js/bootstrap-scrollspy.js +0 -151
- data/docs/assets/js/bootstrap-tab.js +0 -135
- data/docs/assets/js/bootstrap-tooltip.js +0 -275
- data/docs/assets/js/bootstrap-transition.js +0 -61
- data/docs/assets/js/bootstrap-typeahead.js +0 -285
- data/docs/assets/js/bootstrap.js +0 -1825
- data/docs/assets/js/bootstrap.min.js +0 -6
- data/docs/assets/js/google-code-prettify/prettify.css +0 -30
- data/docs/assets/js/google-code-prettify/prettify.js +0 -28
- data/docs/assets/js/jquery.js +0 -9252
- data/docs/base-css.html +0 -1710
- data/docs/build/index.js +0 -44
- data/docs/build/node_modules/.bin/hulk +0 -93
- data/docs/build/node_modules/hogan.js/.git_ignore +0 -1
- data/docs/build/node_modules/hogan.js/.gitmodules +0 -3
- data/docs/build/node_modules/hogan.js/LICENSE +0 -177
- data/docs/build/node_modules/hogan.js/Makefile +0 -62
- data/docs/build/node_modules/hogan.js/README.md +0 -93
- data/docs/build/node_modules/hogan.js/bin/hulk +0 -93
- data/docs/build/node_modules/hogan.js/lib/compiler.js +0 -348
- data/docs/build/node_modules/hogan.js/lib/hogan.js +0 -20
- data/docs/build/node_modules/hogan.js/lib/template.js +0 -233
- data/docs/build/node_modules/hogan.js/package.json +0 -20
- data/docs/build/node_modules/hogan.js/test/html/list.html +0 -8
- data/docs/build/node_modules/hogan.js/test/index.html +0 -13
- data/docs/build/node_modules/hogan.js/test/index.js +0 -848
- data/docs/build/node_modules/hogan.js/test/mustache.js +0 -90
- data/docs/build/node_modules/hogan.js/test/spec.js +0 -77
- data/docs/build/node_modules/hogan.js/test/spec/Changes +0 -31
- data/docs/build/node_modules/hogan.js/test/spec/README.md +0 -65
- data/docs/build/node_modules/hogan.js/test/spec/Rakefile +0 -27
- data/docs/build/node_modules/hogan.js/test/spec/TESTING.md +0 -46
- data/docs/build/node_modules/hogan.js/test/spec/specs/comments.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/comments.yml +0 -103
- data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/delimiters.yml +0 -158
- data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/interpolation.yml +0 -230
- data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/inverted.yml +0 -193
- data/docs/build/node_modules/hogan.js/test/spec/specs/partials.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/partials.yml +0 -109
- data/docs/build/node_modules/hogan.js/test/spec/specs/sections.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/sections.yml +0 -256
- data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.json +0 -1
- data/docs/build/node_modules/hogan.js/test/spec/specs/~lambdas.yml +0 -149
- data/docs/build/node_modules/hogan.js/test/templates/list.mustache +0 -8
- data/docs/build/node_modules/hogan.js/tools/release.js +0 -74
- data/docs/build/node_modules/hogan.js/tools/web_templates.js +0 -32
- data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.js +0 -500
- data/docs/build/node_modules/hogan.js/web/1.0.0/hogan.min.js +0 -14
- data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.js +0 -500
- data/docs/build/node_modules/hogan.js/web/builds/1.0.0/hogan.min.js +0 -14
- data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.js +0 -545
- data/docs/build/node_modules/hogan.js/web/builds/1.0.3/hogan.min.js +0 -5
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.amd.js +0 -576
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.common.js +0 -576
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.js +0 -572
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.amd.js +0 -5
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.common.js +0 -5
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.js +0 -5
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.min.mustache.js +0 -5
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/hogan-1.0.5.mustache.js +0 -619
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.js +0 -233
- data/docs/build/node_modules/hogan.js/web/builds/1.0.5/template-1.0.5.min.js +0 -5
- data/docs/build/node_modules/hogan.js/web/favicon.ico +0 -0
- data/docs/build/node_modules/hogan.js/web/images/logo.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/noise.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/small-hogan-icon.png +0 -0
- data/docs/build/node_modules/hogan.js/web/images/stripes.png +0 -0
- data/docs/build/node_modules/hogan.js/web/index.html.mustache +0 -139
- data/docs/build/node_modules/hogan.js/web/stylesheets/layout.css +0 -206
- data/docs/build/node_modules/hogan.js/web/stylesheets/skeleton.css +0 -236
- data/docs/build/node_modules/hogan.js/wrappers/amd.js.mustache +0 -21
- data/docs/build/node_modules/hogan.js/wrappers/common.js.mustache +0 -21
- data/docs/build/node_modules/hogan.js/wrappers/js.mustache +0 -17
- data/docs/build/node_modules/hogan.js/wrappers/mustache.js.mustache +0 -64
- data/docs/build/package.json +0 -6
- data/docs/components.html +0 -1931
- data/docs/download.html +0 -454
- data/docs/examples.html +0 -147
- data/docs/examples/fluid.html +0 -162
- data/docs/examples/hero.html +0 -109
- data/docs/examples/starter-template.html +0 -79
- data/docs/index.html +0 -259
- data/docs/javascript.html +0 -1520
- data/docs/less.html +0 -1060
- data/docs/scaffolding.html +0 -671
- data/docs/templates/layout.mustache +0 -146
- data/docs/templates/pages/base-css.mustache +0 -1594
- data/docs/templates/pages/components.mustache +0 -1815
- data/docs/templates/pages/download.mustache +0 -338
- data/docs/templates/pages/examples.mustache +0 -31
- data/docs/templates/pages/index.mustache +0 -144
- data/docs/templates/pages/javascript.mustache +0 -1405
- data/docs/templates/pages/less.mustache +0 -944
- data/docs/templates/pages/scaffolding.mustache +0 -555
- data/docs/templates/pages/upgrading.mustache +0 -194
- data/docs/upgrading.html +0 -310
- data/js/tests/index.html +0 -54
- data/js/tests/phantom.js +0 -63
- data/js/tests/server.js +0 -14
- data/js/tests/unit/bootstrap-alert.js +0 -56
- data/js/tests/unit/bootstrap-button.js +0 -77
- data/js/tests/unit/bootstrap-carousel.js +0 -28
- data/js/tests/unit/bootstrap-collapse.js +0 -54
- data/js/tests/unit/bootstrap-dropdown.js +0 -87
- data/js/tests/unit/bootstrap-modal.js +0 -114
- data/js/tests/unit/bootstrap-phantom.js +0 -21
- data/js/tests/unit/bootstrap-popover.js +0 -93
- data/js/tests/unit/bootstrap-scrollspy.js +0 -31
- data/js/tests/unit/bootstrap-tab.js +0 -61
- data/js/tests/unit/bootstrap-tooltip.js +0 -155
- data/js/tests/unit/bootstrap-transition.js +0 -13
- data/js/tests/unit/bootstrap-typeahead.js +0 -148
- data/js/tests/vendor/jquery.js +0 -9252
- data/js/tests/vendor/qunit.css +0 -232
- data/js/tests/vendor/qunit.js +0 -1510
- data/package.json +0 -25
- data/sass-twitter-bootstrap.gemspec +0 -19
- data/vendor/assets/javascripts/README.md +0 -112
- data/vendor/assets/javascripts/twitter/bootstrap.js +0 -12
- data/vendor/assets/stylesheets/twitter/_labels-badges.scss +0 -52
- data/vendor/assets/stylesheets/twitter/_responsive-1200px-min.scss +0 -26
- data/vendor/assets/stylesheets/twitter/_responsive-767px-max.scss +0 -149
- data/vendor/assets/stylesheets/twitter/_responsive-768px-979px.scss +0 -17
- data/vendor/assets/stylesheets/twitter/_responsive-navbar.scss +0 -153
- data/vendor/assets/stylesheets/twitter/_responsive-utilities.scss +0 -41
@@ -1,93 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/*
|
4
|
-
* Copyright 2011 Twitter, Inc.
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*/
|
17
|
-
|
18
|
-
var hogan = require('../lib/hogan.js'),
|
19
|
-
path = require('path'),
|
20
|
-
fs = require('fs');
|
21
|
-
|
22
|
-
var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'],
|
23
|
-
specialsRegExp = new RegExp('(\\' + specials.join('|\\') + ')', 'g'),
|
24
|
-
templates;
|
25
|
-
|
26
|
-
|
27
|
-
// Escape special regexp characters
|
28
|
-
function esc(text) {
|
29
|
-
return text.replace(specialsRegExp, '\\$1');
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
// Check for dirs and correct ext (<3 for windows)
|
34
|
-
function extractFiles(args) {
|
35
|
-
var usage = 'USAGE: hulk ./templates/*.mustaches\n' +
|
36
|
-
'NOTE: hulk supports the "*" wildcard and allows you to target specific extensions too',
|
37
|
-
files = [];
|
38
|
-
|
39
|
-
if (!args.length) {
|
40
|
-
console.log(usage);
|
41
|
-
process.exit(-1);
|
42
|
-
}
|
43
|
-
|
44
|
-
args.forEach(function (arg) {
|
45
|
-
|
46
|
-
if (/\*/.test(arg)) {
|
47
|
-
arg = arg.split('*');
|
48
|
-
return files = files.concat(
|
49
|
-
fs.readdirSync(arg[0] || '.')
|
50
|
-
.map(function (f) {
|
51
|
-
return new RegExp(esc(arg[1]) + '$').test(f) && path.join(arg[0], f);
|
52
|
-
})
|
53
|
-
.filter(function (f) {
|
54
|
-
return f;
|
55
|
-
})
|
56
|
-
);
|
57
|
-
}
|
58
|
-
|
59
|
-
files.push(arg);
|
60
|
-
|
61
|
-
})
|
62
|
-
|
63
|
-
return files;
|
64
|
-
}
|
65
|
-
|
66
|
-
|
67
|
-
// Remove utf-8 byte order mark, http://en.wikipedia.org/wiki/Byte_order_mark
|
68
|
-
function removeByteOrderMark(text) {
|
69
|
-
if (text.charCodeAt(0) === 0xfeff) {
|
70
|
-
return text.substring(1);
|
71
|
-
}
|
72
|
-
return text;
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
// Write a template foreach file that matches template extension
|
77
|
-
templates = extractFiles(process.argv.slice(2))
|
78
|
-
.map(function (file) {
|
79
|
-
var openedFile = fs.readFileSync(file, 'utf-8'), name;
|
80
|
-
if (!openedFile) return;
|
81
|
-
name = file.replace(/\..*$/, '');
|
82
|
-
openedFile = removeByteOrderMark(openedFile.trim());
|
83
|
-
return 'templates.' + name + ' = new Hogan.Template(' + hogan.compile(openedFile, { asString: 1 }) + ');';
|
84
|
-
})
|
85
|
-
.filter(function (t) {
|
86
|
-
return t;
|
87
|
-
});
|
88
|
-
|
89
|
-
|
90
|
-
// Output templates
|
91
|
-
if (!templates.length) return;
|
92
|
-
console.log('var templates = {};');
|
93
|
-
console.log(templates.join('\n'));
|
@@ -1,348 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
(function (Hogan) {
|
17
|
-
// Setup regex assignments
|
18
|
-
// remove whitespace according to Mustache spec
|
19
|
-
var rIsWhitespace = /\S/,
|
20
|
-
rQuot = /\"/g,
|
21
|
-
rNewline = /\n/g,
|
22
|
-
rCr = /\r/g,
|
23
|
-
rSlash = /\\/g,
|
24
|
-
tagTypes = {
|
25
|
-
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
|
26
|
-
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
|
27
|
-
};
|
28
|
-
|
29
|
-
Hogan.scan = function scan(text, delimiters) {
|
30
|
-
var len = text.length,
|
31
|
-
IN_TEXT = 0,
|
32
|
-
IN_TAG_TYPE = 1,
|
33
|
-
IN_TAG = 2,
|
34
|
-
state = IN_TEXT,
|
35
|
-
tagType = null,
|
36
|
-
tag = null,
|
37
|
-
buf = '',
|
38
|
-
tokens = [],
|
39
|
-
seenTag = false,
|
40
|
-
i = 0,
|
41
|
-
lineStart = 0,
|
42
|
-
otag = '{{',
|
43
|
-
ctag = '}}';
|
44
|
-
|
45
|
-
function addBuf() {
|
46
|
-
if (buf.length > 0) {
|
47
|
-
tokens.push(new String(buf));
|
48
|
-
buf = '';
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
function lineIsWhitespace() {
|
53
|
-
var isAllWhitespace = true;
|
54
|
-
for (var j = lineStart; j < tokens.length; j++) {
|
55
|
-
isAllWhitespace =
|
56
|
-
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
|
57
|
-
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
|
58
|
-
if (!isAllWhitespace) {
|
59
|
-
return false;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
return isAllWhitespace;
|
64
|
-
}
|
65
|
-
|
66
|
-
function filterLine(haveSeenTag, noNewLine) {
|
67
|
-
addBuf();
|
68
|
-
|
69
|
-
if (haveSeenTag && lineIsWhitespace()) {
|
70
|
-
for (var j = lineStart, next; j < tokens.length; j++) {
|
71
|
-
if (!tokens[j].tag) {
|
72
|
-
if ((next = tokens[j+1]) && next.tag == '>') {
|
73
|
-
// set indent to token value
|
74
|
-
next.indent = tokens[j].toString()
|
75
|
-
}
|
76
|
-
tokens.splice(j, 1);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
} else if (!noNewLine) {
|
80
|
-
tokens.push({tag:'\n'});
|
81
|
-
}
|
82
|
-
|
83
|
-
seenTag = false;
|
84
|
-
lineStart = tokens.length;
|
85
|
-
}
|
86
|
-
|
87
|
-
function changeDelimiters(text, index) {
|
88
|
-
var close = '=' + ctag,
|
89
|
-
closeIndex = text.indexOf(close, index),
|
90
|
-
delimiters = trim(
|
91
|
-
text.substring(text.indexOf('=', index) + 1, closeIndex)
|
92
|
-
).split(' ');
|
93
|
-
|
94
|
-
otag = delimiters[0];
|
95
|
-
ctag = delimiters[1];
|
96
|
-
|
97
|
-
return closeIndex + close.length - 1;
|
98
|
-
}
|
99
|
-
|
100
|
-
if (delimiters) {
|
101
|
-
delimiters = delimiters.split(' ');
|
102
|
-
otag = delimiters[0];
|
103
|
-
ctag = delimiters[1];
|
104
|
-
}
|
105
|
-
|
106
|
-
for (i = 0; i < len; i++) {
|
107
|
-
if (state == IN_TEXT) {
|
108
|
-
if (tagChange(otag, text, i)) {
|
109
|
-
--i;
|
110
|
-
addBuf();
|
111
|
-
state = IN_TAG_TYPE;
|
112
|
-
} else {
|
113
|
-
if (text.charAt(i) == '\n') {
|
114
|
-
filterLine(seenTag);
|
115
|
-
} else {
|
116
|
-
buf += text.charAt(i);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
} else if (state == IN_TAG_TYPE) {
|
120
|
-
i += otag.length - 1;
|
121
|
-
tag = tagTypes[text.charAt(i + 1)];
|
122
|
-
tagType = tag ? text.charAt(i + 1) : '_v';
|
123
|
-
if (tagType == '=') {
|
124
|
-
i = changeDelimiters(text, i);
|
125
|
-
state = IN_TEXT;
|
126
|
-
} else {
|
127
|
-
if (tag) {
|
128
|
-
i++;
|
129
|
-
}
|
130
|
-
state = IN_TAG;
|
131
|
-
}
|
132
|
-
seenTag = i;
|
133
|
-
} else {
|
134
|
-
if (tagChange(ctag, text, i)) {
|
135
|
-
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
|
136
|
-
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
|
137
|
-
buf = '';
|
138
|
-
i += ctag.length - 1;
|
139
|
-
state = IN_TEXT;
|
140
|
-
if (tagType == '{') {
|
141
|
-
if (ctag == '}}') {
|
142
|
-
i++;
|
143
|
-
} else {
|
144
|
-
cleanTripleStache(tokens[tokens.length - 1]);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
} else {
|
148
|
-
buf += text.charAt(i);
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
filterLine(seenTag, true);
|
154
|
-
|
155
|
-
return tokens;
|
156
|
-
}
|
157
|
-
|
158
|
-
function cleanTripleStache(token) {
|
159
|
-
if (token.n.substr(token.n.length - 1) === '}') {
|
160
|
-
token.n = token.n.substring(0, token.n.length - 1);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
function trim(s) {
|
165
|
-
if (s.trim) {
|
166
|
-
return s.trim();
|
167
|
-
}
|
168
|
-
|
169
|
-
return s.replace(/^\s*|\s*$/g, '');
|
170
|
-
}
|
171
|
-
|
172
|
-
function tagChange(tag, text, index) {
|
173
|
-
if (text.charAt(index) != tag.charAt(0)) {
|
174
|
-
return false;
|
175
|
-
}
|
176
|
-
|
177
|
-
for (var i = 1, l = tag.length; i < l; i++) {
|
178
|
-
if (text.charAt(index + i) != tag.charAt(i)) {
|
179
|
-
return false;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
return true;
|
184
|
-
}
|
185
|
-
|
186
|
-
function buildTree(tokens, kind, stack, customTags) {
|
187
|
-
var instructions = [],
|
188
|
-
opener = null,
|
189
|
-
token = null;
|
190
|
-
|
191
|
-
while (tokens.length > 0) {
|
192
|
-
token = tokens.shift();
|
193
|
-
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
|
194
|
-
stack.push(token);
|
195
|
-
token.nodes = buildTree(tokens, token.tag, stack, customTags);
|
196
|
-
instructions.push(token);
|
197
|
-
} else if (token.tag == '/') {
|
198
|
-
if (stack.length === 0) {
|
199
|
-
throw new Error('Closing tag without opener: /' + token.n);
|
200
|
-
}
|
201
|
-
opener = stack.pop();
|
202
|
-
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
|
203
|
-
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
|
204
|
-
}
|
205
|
-
opener.end = token.i;
|
206
|
-
return instructions;
|
207
|
-
} else {
|
208
|
-
instructions.push(token);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
|
212
|
-
if (stack.length > 0) {
|
213
|
-
throw new Error('missing closing tag: ' + stack.pop().n);
|
214
|
-
}
|
215
|
-
|
216
|
-
return instructions;
|
217
|
-
}
|
218
|
-
|
219
|
-
function isOpener(token, tags) {
|
220
|
-
for (var i = 0, l = tags.length; i < l; i++) {
|
221
|
-
if (tags[i].o == token.n) {
|
222
|
-
token.tag = '#';
|
223
|
-
return true;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
}
|
227
|
-
|
228
|
-
function isCloser(close, open, tags) {
|
229
|
-
for (var i = 0, l = tags.length; i < l; i++) {
|
230
|
-
if (tags[i].c == close && tags[i].o == open) {
|
231
|
-
return true;
|
232
|
-
}
|
233
|
-
}
|
234
|
-
}
|
235
|
-
|
236
|
-
function writeCode(tree) {
|
237
|
-
return 'i = i || "";var b = i + "";var _ = this;' + walk(tree) + 'return b;';
|
238
|
-
}
|
239
|
-
|
240
|
-
Hogan.generate = function (code, text, options) {
|
241
|
-
if (options.asString) {
|
242
|
-
return 'function(c,p,i){' + code + ';}';
|
243
|
-
}
|
244
|
-
|
245
|
-
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan);
|
246
|
-
}
|
247
|
-
|
248
|
-
function esc(s) {
|
249
|
-
return s.replace(rSlash, '\\\\')
|
250
|
-
.replace(rQuot, '\\\"')
|
251
|
-
.replace(rNewline, '\\n')
|
252
|
-
.replace(rCr, '\\r');
|
253
|
-
}
|
254
|
-
|
255
|
-
function chooseMethod(s) {
|
256
|
-
return (~s.indexOf('.')) ? 'd' : 'f';
|
257
|
-
}
|
258
|
-
|
259
|
-
function walk(tree) {
|
260
|
-
var code = '';
|
261
|
-
for (var i = 0, l = tree.length; i < l; i++) {
|
262
|
-
var tag = tree[i].tag;
|
263
|
-
if (tag == '#') {
|
264
|
-
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
|
265
|
-
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
|
266
|
-
} else if (tag == '^') {
|
267
|
-
code += invertedSection(tree[i].nodes, tree[i].n,
|
268
|
-
chooseMethod(tree[i].n));
|
269
|
-
} else if (tag == '<' || tag == '>') {
|
270
|
-
code += partial(tree[i]);
|
271
|
-
} else if (tag == '{' || tag == '&') {
|
272
|
-
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
|
273
|
-
} else if (tag == '\n') {
|
274
|
-
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
|
275
|
-
} else if (tag == '_v') {
|
276
|
-
code += variable(tree[i].n, chooseMethod(tree[i].n));
|
277
|
-
} else if (tag === undefined) {
|
278
|
-
code += text('"' + esc(tree[i]) + '"');
|
279
|
-
}
|
280
|
-
}
|
281
|
-
return code;
|
282
|
-
}
|
283
|
-
|
284
|
-
function section(nodes, id, method, start, end, tags) {
|
285
|
-
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
|
286
|
-
'c,p,0,' + start + ',' + end + ', "' + tags + '")){' +
|
287
|
-
'b += _.rs(c,p,' +
|
288
|
-
'function(c,p){ var b = "";' +
|
289
|
-
walk(nodes) +
|
290
|
-
'return b;});c.pop();}' +
|
291
|
-
'else{b += _.b; _.b = ""};';
|
292
|
-
}
|
293
|
-
|
294
|
-
function invertedSection(nodes, id, method) {
|
295
|
-
return 'if (!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
|
296
|
-
walk(nodes) +
|
297
|
-
'};';
|
298
|
-
}
|
299
|
-
|
300
|
-
function partial(tok) {
|
301
|
-
return 'b += _.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '");';
|
302
|
-
}
|
303
|
-
|
304
|
-
function tripleStache(id, method) {
|
305
|
-
return 'b += (_.' + method + '("' + esc(id) + '",c,p,0));';
|
306
|
-
}
|
307
|
-
|
308
|
-
function variable(id, method) {
|
309
|
-
return 'b += (_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
|
310
|
-
}
|
311
|
-
|
312
|
-
function text(id) {
|
313
|
-
return 'b += ' + id + ';';
|
314
|
-
}
|
315
|
-
|
316
|
-
Hogan.parse = function(tokens, options) {
|
317
|
-
options = options || {};
|
318
|
-
return buildTree(tokens, '', [], options.sectionTags || []);
|
319
|
-
},
|
320
|
-
|
321
|
-
Hogan.cache = {};
|
322
|
-
|
323
|
-
Hogan.compile = function(text, options) {
|
324
|
-
// options
|
325
|
-
//
|
326
|
-
// asString: false (default)
|
327
|
-
//
|
328
|
-
// sectionTags: [{o: '_foo', c: 'foo'}]
|
329
|
-
// An array of object with o and c fields that indicate names for custom
|
330
|
-
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
|
331
|
-
//
|
332
|
-
// delimiters: A string that overrides the default delimiters.
|
333
|
-
// Example: "<% %>"
|
334
|
-
//
|
335
|
-
options = options || {};
|
336
|
-
|
337
|
-
var key = text + '||' + !!options.asString;
|
338
|
-
|
339
|
-
var t = this.cache[key];
|
340
|
-
|
341
|
-
if (t) {
|
342
|
-
return t;
|
343
|
-
}
|
344
|
-
|
345
|
-
t = this.generate(writeCode(this.parse(this.scan(text, options.delimiters), options)), text, options);
|
346
|
-
return this.cache[key] = t;
|
347
|
-
};
|
348
|
-
})(typeof exports !== 'undefined' ? exports : Hogan);
|
@@ -1,20 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
// This file is for use with Node.js. See dist/ for browser files.
|
17
|
-
|
18
|
-
var Hogan = require('./compiler');
|
19
|
-
Hogan.Template = require('./template').Template;
|
20
|
-
module.exports = Hogan;
|