Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Seems to be a feature, not a bug (handlebars-lang/handlebars.js#857) …
Browse files Browse the repository at this point in the history
…so back to Handlebars v2.0.0. Adapted playtotv-define.js.hbs template to work with standalone block whitespace removal. Removed em-define template since it was not really being used.
  • Loading branch information
difosfor committed Sep 5, 2014
1 parent c7098b2 commit 3a10d6b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 102 deletions.
4 changes: 3 additions & 1 deletion lib/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Handlebars.registerHelper('join', function(list, options) {
Handlebars.registerHelper('replace', function(options) {
var hash = options.hash;
var regexp = new RegExp(hash.regexp, hash.flags || '');
return options.fn(this).replace(regexp, hash.by || '');
var by = hash.by || '';
by = by.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
return options.fn(this).replace(regexp, by);
});

Handlebars.registerHelper('partial', function(name, options) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"chokidar": "~0.6.3",
"connect": "~2.17.1",
"es6-promise": "~0.1.1",
"handlebars": "2.0.0-alpha.4",
"handlebars": "~2.0.0",
"jscs": "~1.6.1",
"jshint": "~2.5.0",
"jsonlint": "~1.6.2",
Expand Down
75 changes: 0 additions & 75 deletions res/em-api/em-define.js.hbs

This file was deleted.

55 changes: 30 additions & 25 deletions res/em-api/playtotv-define.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,63 @@ playtotv.define('{{modulePackage}}.{{moduleName}}', [], function() {
/*jshint maxlen:300*/ // On occassion generated lines can be too long

/** @lends {{modulePackage}}.{{moduleName}} */
{{#join methods separator=",\n"}}

{{#join methods separator=",\n\n"}}
/**
{{~#partial "enum-values"}}{{#if enumValues}} Valid values: {{#join enumValues}}'{{.}}'{{/join}}{{/if}}{{/partial}}
{{~#partial "dto-params"}}
{{#partial "dto-params"}}
* <ul>
{{~#.}}
* <li><i>{ {{~type~}} }</i> <b>{{name}}</b>{{> enum-values}}{{#if pojo}}{{#with pojo.fieldsData}}{{> dto-params}}{{/with}}{{/if}}</li>
{{~/.}}
{{#.}}
* <li><i>{ {{~type~}} }</i> <b>{{name}}</b>{{> enum-values}}{{#if pojo}}
{{#with pojo.fieldsData}}{{> dto-params}}{{/with}}{{/if}}</li>
{{/.}}
* </ul>
{{~/partial}}
{{~#if requestDTOs.length}}
{{#if requestDTOs.length}}
* <b>Request DTO's:</b>
{{~#with requestDTOs}}{{> dto-params}}{{/with}}
{{#with requestDTOs}}{{> dto-params}}{{/with}}
*
{{~/if}}
{{~#if responseVar.pojo}}
{{/if}}
{{#if responseVar.pojo}}
* <b>Response data:</b>
{{~#with responseVar.pojo.fieldsData}}{{> dto-params}}{{/with}}
{{#with responseVar.pojo.fieldsData}}{{> dto-params}}{{/with}}
*
{{~/if}}
{{/if}}
* @function
{{~#if params.length}}
{{#if params.length}}
* @param {Object} params
{{~#params}}
{{#params}}
* @param { {{~type~}} } {{#if optional}}[{{/if}}params.{{name}}{{#if defaultValue}}={{defaultValue}}{{/if}}{{#if optional}}]{{/if}}{{> enum-values}}
{{~/params}}
{{~/if}}
{{/params}}
{{/if}}
* @returns {Promise} Promise of response data ({{responseVar.type}})
*/
{{name}}: {
{{~#replace regexp=",$"}}{{!-- Strip final comma and newline --}}
{{#replace regexp=",\n$" by="\n"}}
label: '{{#replace regexp="API$"}}{{moduleName}}{{/replace}}.{{name}}',
url: '{{url}}',
{{~#unless-equal type to="GET"}}
{{#unless-equal type to="GET"}}
type: '{{type}}',
{{~/unless-equal}}
{{~#if queryVars.length}}
{{/unless-equal}}
{{#if queryVars.length}}
queryKeys: [
{{~#join queryVars separator=","}}
{{#join queryVars separator=",\n"}}
'{{name}}'
{{~/join}}

],
{{~/if}}
{{~#if requestVars.length}}
{{/if}}
{{#if requestVars.length}}
dataKeys: [
{{~#join requestVars separator=","}}
{{#join requestVars separator=",\n"}}
'{{name}}'
{{~/join}}

]
{{~/if}}
{{~/replace}}
{{/if}}
{{/replace}}
}
{{~/join}}

};
});

0 comments on commit 3a10d6b

Please sign in to comment.