Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform nested object #33

Open
chsakell opened this issue Apr 6, 2019 · 0 comments
Open

Transform nested object #33

chsakell opened this issue Apr 6, 2019 · 0 comments

Comments

@chsakell
Copy link

chsakell commented Apr 6, 2019

Is it possible to transform nested objects?
Let's say we have an object with a liveData property which is an object with nested objects...

"liveData": {
   "score": {
      "home": "1",
      "away": "0"
   },
   "clock": {
      "secondsSinceStart": 3792,
      "clockStopped": false
   }
}

.. and we need to tranform it to the following:

"live": {
   "sc": {
      "h": "0",
      "a": "0"
   },
   "t": {
      "s": 3792,
      "st": false
   }
}

So what is the template for livedata object?
I tried the following approach but no luck.

import livedataTemplate from './livedata.template';
let template = "live": livedataTemplate;

livedataTemplate looks like this.

import scoreTemplate from './score.template';
import clockTemplate from './clock.template';

export default {
    "{{livedata}}": {
        "sc": scoreTemplate,
        "t": clockTemplate
    }

.. score / clock templates respectively..

export default {
    "{{score}}": {
        "h": "{{home}}",
        "a": "{{away}}"
    }
}
export default {
    "{{clock}}": {
        "s": "{{secondsSinceStart}}",
        "st": "{{clockStopped}}"
    }
}

what am I doing wrong? any help would be appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant