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

How includes work / can we shift data context for includes? #87

Open
OndrejValenta opened this issue Jun 15, 2024 · 0 comments
Open

How includes work / can we shift data context for includes? #87

OndrejValenta opened this issue Jun 15, 2024 · 0 comments

Comments

@OndrejValenta
Copy link

Hi,
I'm just playing with Mikado and I'm actually confused how includes work.

For this data..

{
    "header": "List of users",
    "users": [
        {
            "username": "User A0",
            "tweets": [
                "foo",
                "bar",
                "foobar"
            ]
        },
        {
            "username": "User A1",
            "tweets": [
                "foo",
                "bar",
                "foobar"
            ]
        }
    ]
}

I've created header.html that looks like this

<h1>{{data.header}}</h1>

row.html as a partial that looks like this

<tr>
  <td>{{ data.username }}</td>
  <td>{{ data.tweets.length }}</td>
</tr>

and list.html that looks like this

<div>
  <div include="build/partials/header"></div>
  <table>
    <thead>
      <tr>
        <th>User</th>
        <th>Tweet count</th>
      </tr>
    </thead>
    <tbody include="build/partials/row"></tbody>
  </table>
</div>

Questions:

  • is there a way to set a context for include, like context=data.users?
  • it seems include is only for enumerables, is there a way to have a "static" component?

Bug:

  • if I put include in table or even tbody tag, whole template is rendered for all rows, including header, is that a desired behavior? Or am I missing something?
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