question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abillity for href to open/render another view/template

See original GitHub issue

Something like that:

      "templates": {
        "body": {
          "sections": [
            {
              "items": {
                "{{#each $jason}}": {
                  "type": "label",
                  "text": "{{article.title}}",
                  "href": {
                    "param-to-pass-data": "{{article}}",
                    "template": "article",
                    "view": "jason"
                  }
                }
              }
            },
          ]
        },
        "article": {...}

It would display another view in a push transition. Data can be passed.

My use case behind: I have everything I need in the first $network.request (a json with a list of articles, with their body). So I don’t need extra http call, etc.

First talk was on slack. Need discussion.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thedumbtechguycommented, Nov 19, 2016

That is perfect then!

I thought it rendered a something like

     "data": "{ \"title\": \"Lorem Ipsum\", \"description\": \"blah blah blah\" }"

That’s a great solution then. I like how we handled raw html display as well with this.

0reactions
gliechtensteincommented, Nov 19, 2016

The way the template engine works is:

  1. It tries its best to render it in the right format.
  2. If that’s not possible, the render it as string.

So for example, let’s say article looked like:

{
  "title": "Lorem Ipsum",
  "description": "blah blah blah"
}

Then when we run it through

{
  "options": {
    "data": "{{article}}"
  }
}

It becomes:

{
  "options": {
    "data": {
      "title": "Lorem Ipsum",
      "description": "blah blah blah"
    }
  }
}

However, if you try to parse the same data with something like this:

{
  "options": {
    "data": "Here's an {{article}}"
  }
}

Then, since you can’t create an object out of this, it stringifies it like:

{
  "options": {
    "data": "Here's an [object Object]"
  }
}

Here’s more example from the test file:

 166     it('standalone this where this is array', function(){
 167       var res = parse.getData( ['item1','item2'], "This is an {{this}}");
 168       assert.equal("This is an item1,item2", res);
 169     });
 170     it('standalone this where this is string', function(){
 171       var res = parse.getData( "item1", "This is an {{this}}");
 172       assert.equal("This is an item1", res);
 173     });
 174     it('standalone this where this is object', function(){
 175       var res = parse.getData( {"key": 'item1'}, "This is an {{this}}");
 176       assert.equal("This is an [object Object]", res);
 177     });

p.s. I’m actually trying to open source this template engine as well. It is already included in the project and you can read the source if you want, but it’s all minified so it’s not really practical at the moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found