Skip to content

Commit 58ff519

Browse files
authored
Merge pull request #29 from fiddlededee/master
added asciidoc template
2 parents 64ebdcb + 3a4e7ce commit 58ff519

30 files changed

+633
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('acceptedValues', items =>{
4+
if(!items) return 'Any';
5+
6+
return items.map(i => `<code>${i}</code>`).join(', ');
7+
});
8+
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('buildPath', (propName, path, key) => {
4+
if (!path) return propName;
5+
return `${path}.${propName}`;
6+
});
7+
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('equal', (lvalue, rvalue, options) => {
4+
if (arguments.length < 3)
5+
throw new Error('Handlebars Helper equal needs 2 parameters');
6+
if (lvalue!==rvalue) {
7+
return options.inverse(this);
8+
}
9+
10+
return options.fn(this);
11+
});
12+
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('isRequired', (obj, key) => {
4+
if (!obj || !obj.required) return false;
5+
return !!(obj.required.includes(key));
6+
});
7+
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('stringify', json => {
4+
if (!(json instanceof String) && typeof json !== 'string' ) {
5+
try {
6+
return JSON.stringify(json || '', null, 2);
7+
} catch (e) {
8+
return '';
9+
}
10+
} else {
11+
return json;
12+
}
13+
});
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
Handlebars.registerHelper('tree', path => {
4+
if (!path) return '';
5+
const filteredPaths = path.split('.').filter(Boolean);
6+
if (!filteredPaths.length) return;
7+
const dottedPath = filteredPaths.join('.');
8+
9+
return `${dottedPath}.`;
10+
});
11+
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
/**
4+
* Uppercases a string.
5+
*/
6+
Handlebars.registerHelper('uppercase', (str) => {
7+
return str.toUpperCase();
8+
});
9+
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = (Handlebars, _) =>{
2+
3+
/**
4+
* Checks if a method is a valid HTTP method.
5+
*/
6+
Handlebars.registerHelper('validMethod', (method, options) => {
7+
const authorized_methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'COPY', 'HEAD', 'OPTIONS', 'LINK', 'UNLIK', 'PURGE', 'LOCK', 'UNLOCK', 'PROPFIND'];
8+
9+
if (arguments.length < 3)
10+
throw new Error('Handlebars Helper validMethod needs 1 parameter');
11+
if (authorized_methods.indexOf(method.toUpperCase()) === -1) {
12+
return options.inverse(this);
13+
}
14+
15+
return options.fn(this);
16+
});
17+
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[discrete]
2+
==== Cookie parameters
3+
4+
{{#each cookieParams as |cookieParam|}}
5+
{{#if cookieParam.name}}
6+
[discrete]
7+
===== {icon-triangle} {{cookieParam.name}}
8+
{{/if}}
9+
10+
{{#if cookieParam.description}}
11+
{{{cookieParam.description}}}
12+
{{/if}}
13+
14+
{{> parameter param=cookieParam paramName=cookieParam.name hideTitle=true}}
15+
16+
{{/each}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[discrete]
2+
===== cURL Script ({i18n-a-generated})
3+
4+
[source]
5+
----
6+
{{{curl}}}
7+
----

0 commit comments

Comments
 (0)