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

improve table template to work better out of the box if data labels change #40

Open
DanielJWood opened this issue Jan 23, 2024 · 2 comments

Comments

@DanielJWood
Copy link
Contributor

Is it worth writing a script that auto generates the columnheaders, and row syntax, instead of you doing it manually each time. Potentially this could be a script run in the google doc in an app script, or something run locally. Basically, ingest column names, spit out html. For instance, for the columns: foo, bar, baz you would get the following:

	<tr>
        <th role="columnheader">
          <div class="sorter"><div class="icon"></div></div>
          <div class="header"><%= COPY.labels.hdr_foo %></div>
        </hr>
        <th role="columnheader">
          <div class="sorter"><div class="icon"></div></div>
          <div class="header"><%= COPY.labels.hdr_bar %></div>
        </hr>
        <th role="columnheader">
          <div class="sorter"><div class="icon"></div></div>
          <div class="header"><%= COPY.labels.hdr_baz %></div>
        </hr>
    </tr>

and

<tr class="tk" role="row">
 <td role="cell" data-title="<%= COPY.labels.hdr_foo %><%= row.foo %></td>
 <td role="cell" data-title="<%= COPY.labels.hdr_bar %><%= row.bar %></td>
 <td role="cell" data-title="<%= COPY.labels.hdr_baz %><%= row.baz %></td>
</tr>

Of course there is always further customization that happens from this point but it could save a bit of time in reformatting the index.html

@thomaswilburn
Copy link
Contributor

thomaswilburn commented Jan 23, 2024

You may want to check out the way we handle this at Chalkbeat, where we have a columns sheet that specifies the field, class name, label, and template functions that can be applied the content. There's no need to get external scripts involved. https://github.com/Chalkbeat/dailygraphics-templates/blob/master/table/index.html

@DanielJWood
Copy link
Contributor Author

Ah great! Will look. Thx.

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

2 participants