Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit fb50a08

Browse files
committed
Merge pull request #6 from mphasize/camelCase
camelCase keys for multi-word models.
2 parents e9d4e2d + d2e36fe commit fb50a08

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sails-generate-ember-blueprints",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Generate a Ember Data compatible blueprints in your Sails project.",
55
"author": {
66
"name": "Marcus Paeschke",

templates/api/blueprints/_util/actionUtil.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ module.exports = {
3131

3232
var plural = Array.isArray( records ) ? true : false;
3333

34-
var documentIdentifier = plural ? pluralize( model.identity ) : model.identity;
34+
var documentIdentifier = plural ? pluralize( model.globalId ) : model.globalId;
35+
//turn id into camelCase for ember
36+
documentIdentifier = documentIdentifier.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,
37+
function(match, index) {
38+
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
39+
return index == 0 ? match.toLowerCase() : match.toUpperCase();
40+
});
3541
var json = {};
3642

3743
json[ documentIdentifier ] = plural ? [] : {};

0 commit comments

Comments
 (0)