Permalink
Browse files

Merge pull request #77 from kss-node/improve-handlebars-code

Improve handlebars code
  • Loading branch information...
2 parents 9fb2657 + e235e63 commit cd81b76648d15d6b2b1e0ada093f54f2b94537d0 @JohnAlbin JohnAlbin committed Jul 19, 2014
Showing with 557 additions and 512 deletions.
  1. +29 −21 bin/kss-node
  2. +65 −63 gh-pages/index.html
  3. +148 −137 gh-pages/section-1.html
  4. +203 −182 gh-pages/section-2.html
  5. +112 −109 lib/template/index.html
View
@@ -146,10 +146,13 @@ process.nextTick(function() {
styleguide = sg;
var sections = styleguide.section('*.'),
- i, sectionCount = sections.length,
- sectionRoots = [], currentRoot,
- rootCount, childSections = [],
- pages = {};
+ sectionCount = sections.length,
+ sectionRoots = [],
+ rootCount,
+ currentRoot,
+ childSections = [],
+ pages = {},
+ i;
console.log(sg.data.files.map(function(file) {
return ' - ' + file
@@ -188,7 +191,7 @@ process.nextTick(function() {
// Compile LESS/Stylus/CSS files into a single "style.css" if required
generateStylesheet = function(argv) {
var compilers = preCompiler.compilers,
- files
+ files;
console.log('...compiling additional stylesheets');
@@ -198,8 +201,8 @@ generateStylesheet = function(argv) {
if (!argv[key]) return;
return {
- files: Array.isArray(argv[key]) ? argv[key] : [argv[key]]
- , type: type
+ files: Array.isArray(argv[key]) ? argv[key] : [argv[key]],
+ type: type
};
});
@@ -208,8 +211,8 @@ generateStylesheet = function(argv) {
async.map(group.files, function (filename, next) {
- var type = group.type
- , extension
+ var type = group.type,
+ extension;
// Type-guessing for --style option
if (!type) {
@@ -320,9 +323,10 @@ jsonModifiers = function(modifiers) {
handlebars.registerHelper('ifAny', function() {
var numItems = arguments.length - 1,
options = arguments[numItems],
- success = true;
+ success = true,
+ i;
- for (var i = 0; i < numItems; i += 1) {
+ for (i = 0; i < numItems; i += 1) {
if (!arguments[i]) {
success = false;
break;
@@ -348,8 +352,9 @@ handlebars.registerHelper('section', function(reference, options) {
* @param {Mixed} query The section query
*/
handlebars.registerHelper('eachSection', function(query, options) {
- var sections,
- i, l, buffer = "";
+ var buffer = '',
+ sections,
+ i, l;
if (!query.match(/x|\*/g)) {
query = new RegExp('^' + query + '$|^' + query + "\\..*");
@@ -369,8 +374,9 @@ handlebars.registerHelper('eachSection', function(query, options) {
* Loop over each section root, i.e. each section only one level deep.
*/
handlebars.registerHelper('eachRoot', function(options) {
- var sections,
- i, l, buffer = "";
+ var buffer = '',
+ sections,
+ i, l;
sections = styleguide.section('x');
if (!sections) return '';
@@ -403,12 +409,14 @@ handlebars.registerHelper('whenDepth', function(depth, options) {
* Similar to the {#eachSection} helper, however will loop over each modifier
* @param {Object} section Supply a section object to loop over it's modifiers. Defaults to the current section.
*/
-handlebars.registerHelper('eachModifier', function(options) {
- var modifiers, i, l, buffer = '';
-
- // Default to current modifiers, but allow supplying a custom section
- if (options.data) modifiers = options.data.modifiers;
- modifiers = modifiers || this.modifiers || false;
+handlebars.registerHelper('eachModifier', function() {
+ var modifiers,
+ options = arguments[arguments.length - 1],
+ buffer = '',
+ i, l;
+
+ // Default to current modifiers, but allow supplying a custom section.
+ modifiers = (arguments.length > 1 && arguments[0].data) ? arguments[0].data.modifiers : this.modifiers;
if (!modifiers) return {};
View
@@ -5,39 +5,37 @@
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
-
<title>KSS: Living Styleguide</title>
+
<meta name="description" content="">
<meta name="generator" content="kss-node" />
-
<meta name="viewport" content="width=device-width">
- <link href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'>
-
+ <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Serif">
<link rel="stylesheet" href="public/kss.css">
<link rel="stylesheet" href="public/style.css">
-
</head>
<body><div id="kss-wrapper">
- <div id="kss-nav">
- <header id="kss-header">
- <hgroup><h1>kss-node Styleguide</h1></hgroup>
- </header>
- <aside>
- <nav><ul>
- <li><a href="index.html">0.0: Overview</a></li>
-
- <li><a href="section-1.html">1.0: Modules</a></li>
-
- <li><a href="section-2.html">2.0: Forms</a></li>
-
- </ul></nav>
- </aside>
- </div>
- <div role="main" id="kss-main">
- <article id="kss-content">
-
- <h1 class="kss-title kss-title-main"> Overview </h1>
+
+<div id="kss-nav">
+ <header id="kss-header">
+ <hgroup><h1>kss-node Styleguide</h1></hgroup>
+ </header>
+ <aside>
+ <nav><ul>
+ <li><a href="index.html">0.0: Overview</a></li>
+
+ <li><a href="section-1.html">1.0: Modules</a></li>
+
+ <li><a href="section-2.html">2.0: Forms</a></li>
+
+ </ul></nav>
+ </aside>
+</div>
+<div role="main" id="kss-main">
+ <article id="kss-content">
+
+ <h1 class="kss-title kss-title-main"> Overview </h1>
<p>This is a demo of <a href="https://github.com/kss-node/kss-node">kss-node</a>&apos;s built-in styleguide generator. The module is essentially a reimplementation of the <a href="https://github.com/kneath/kss">KSS</a> Ruby parser, in Node:
@@ -235,46 +233,50 @@ <h1 class="kss-title kss-title-main"> Overview </h1>
<p>The goal here is to create an organizational structure that is flexible, but rigid enough to be machine processed and referenced inside of documentation.
</p>
-
- </article>
- </div>
- <footer>
- <a href="https://github.com/kss-node/kss-node"><img id="kss-github" style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub"></a>
- </footer>
- <!-- SCRIPTS -->
- <script src="public/kss.js"></script>
- <script src="public/prettify.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- var sidebarAdjust = function() {
- // Match footer/body height
- var height = Math.max($(window).height(), $('#kss-main').height());
-
- if ($(window).width() <= 768) {
- $('#kss-main, #kss-nav').height('auto');
- } else {
- $('#kss-main, #kss-nav').height(height);
- }
- };
-
- $(window).resize(sidebarAdjust);
- $(window).scroll(sidebarAdjust);
- sidebarAdjust();
-
- // Ensure code blocks are highlighted properly...
- $('pre>code').addClass('prettyprint');
- prettyPrint();
-
- });
+
+ </article>
+</div>
+
+
+<footer>
+ <a href="https://github.com/you"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
+</footer>
+
+
+<!-- SCRIPTS -->
+<script src="public/kss.js"></script>
+<script src="public/prettify.js"></script>
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+<script>
+ $(document).ready(function(){
+ var sidebarAdjust = function() {
+ // Match footer/body height
+ var height = Math.max($(window).height(), $('#kss-main').height());
+
+ if ($(window).width() <= 768) {
+ $('#kss-main, #kss-nav').height('auto');
+ } else {
+ $('#kss-main, #kss-nav').height(height);
+ }
+ };
+
+ $(window).resize(sidebarAdjust);
+ $(window).scroll(sidebarAdjust);
+ sidebarAdjust();
+
+ // Ensure code blocks are highlighted properly...
+ $('pre>code').addClass('prettyprint');
+ prettyPrint();
+ });
+</script>
+
+
+
+ <script type="text/javascript">
+ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-12249588-4']); _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>
-
-
- <script type="text/javascript">
- var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-12249588-4']); _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>
-
+
</div></body>
</html>
Oops, something went wrong.

0 comments on commit cd81b76

Please sign in to comment.