Skip to content

Commit

Permalink
Allow whitespace in apiName and apiGroup.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed May 28, 2013
1 parent ba1cc48 commit 1ebf30f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/parser_api_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function parse(content)

if(content.length === 0) return null;
return {
group: content
group: content.replace(/(\s+)/g, "_")
};
} // parse

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/parser_api_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function parse(content)

if(content.length === 0) return null;
return {
name: content
name: content.replace(/(\s+)/g, "_")
};
} // parse

Expand Down
11 changes: 9 additions & 2 deletions template/handlebars_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ define([
};

/**
* Liefert den lokalisierten Text zurück.
*
* Return localized Text.
* @param string text
*/
Handlebars.registerHelper("__", function(text){
return locale.__(text);
});

/**
* Replace underscore with space.
* @param string text
*/
Handlebars.registerHelper("underscoreToSpace", function(text){
return text.replace(/(_+)/g, " ");
});

/**
*
*/
Expand Down
10 changes: 5 additions & 5 deletions template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
{{#each nav}}
{{#if isHeader}}
{{#if isFixed}}
<li class="nav-fixed nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{title}}</a></li>
<li class="nav-fixed nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{else}}
<li class="nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{title}}</a></li>
<li class="nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{/if}}
{{else}}
<li {{#if hidden}}class="hide" {{/if}}data-group="{{group}}" data-name="{{name}}" data-version="{{version}}"><a href="#api-{{group}}-{{name}}">{{title}}</a></li>
Expand Down Expand Up @@ -65,7 +65,7 @@ <h1>{{name}}</h1>

<script id="template-sections" type="text/x-handlebars-template">
<section id="api-{{group}}">
<h1>{{title}}</h1>
<h1>{{underscoreToSpace title}}</h1>
{{#each articles}}
<div id="api-{{group}}-{{name}}">
{{{article}}}
Expand All @@ -77,7 +77,7 @@ <h1>{{title}}</h1>
<script id="template-article" type="text/x-handlebars-template">
<article id="api-{{article.group}}-{{article.name}}-{{article.version}}" {{#if hidden}}class="hide"{{/if}} data-group="{{article.group}}" data-name="{{article.name}}" data-version="{{article.version}}">
<div class="pull-left">
<h1>{{article.group}} - {{article.title}}</h1>
<h1>{{underscoreToSpace article.group}} - {{article.title}}</h1>
</div>
<div class="pull-right">
<div class="btn-group">
Expand Down Expand Up @@ -163,7 +163,7 @@ <h2>{{__ _title}}</h2>
<script id="template-compare-article" type="text/x-handlebars-template">
<article id="api-{{article.group}}-{{article.name}}-{{article.version}}" {{#if hidden}}class="hide"{{/if}} data-group="{{article.group}}" data-name="{{article.name}}" data-version="{{article.version}}" data-compare-version="{{compare.version}}">
<div class="pull-left">
<h1>{{article.group}} - {{{showDiff article.title compare.title}}}</h1>
<h1>{{underscoreToSpace article.group}} - {{{showDiff article.title compare.title}}}</h1>
</div>

<div class="pull-right">
Expand Down
11 changes: 9 additions & 2 deletions template_basic/handlebars_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ define([
], function(locale, Handlebars) {

/**
* Liefert den lokalisierten Text zurück.
*
* Return localized Text.
* @param string text
*/
Handlebars.registerHelper("__", function(text){
return locale.__(text);
});

/**
* Replace underscore with space.
* @param string text
*/
Handlebars.registerHelper("underscoreToSpace", function(text){
return text.replace(/(_+)/g, " ");
});

/**
*
*/
Expand Down
8 changes: 4 additions & 4 deletions template_basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
{{#each nav}}
{{#if isHeader}}
{{#if isFixed}}
<li class="nav-fixed nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{title}}</a></li>
<li class="nav-fixed nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{else}}
<li class="nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{title}}</a></li>
<li class="nav-header" data-group="{{group}}"><a href="#api-{{group}}">{{underscoreToSpace title}}</a></li>
{{/if}}
{{else}}
<li {{#if hidden}}class="hide" {{/if}}data-group="{{group}}" data-name="{{name}}" data-version="{{version}}"><a href="#api-{{group}}-{{name}}">{{title}}</a></li>
Expand Down Expand Up @@ -57,7 +57,7 @@ <h1>{{name}}</h1>

<script id="template-sections" type="text/x-handlebars-template">
<section id="api-{{group}}">
<h1>{{title}}</h1>
<h1>{{underscoreToSpace title}}</h1>
{{#each articles}}
<div id="api-{{group}}-{{name}}">
{{{article}}}
Expand All @@ -69,7 +69,7 @@ <h1>{{title}}</h1>
<script id="template-article" type="text/x-handlebars-template">
<article id="api-{{article.group}}-{{article.name}}-{{article.version}}" {{#if hidden}}class="hide"{{/if}} data-group="{{article.group}}" data-name="{{article.name}}" data-version="{{article.version}}">
<div class="pull-left">
<h1>{{article.group}} - {{article.title}}</h1>
<h1>{{underscoreToSpace article.group}} - {{article.title}}</h1>
</div>
<div class="pull-right">
<div class="btn-group">
Expand Down

0 comments on commit 1ebf30f

Please sign in to comment.