
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
html-tabled
Advanced tools
Data-driven HTML tables with vanilla JavaScript
<table>
  <thead>
    <tr>
      <th>First Name</td>
      <th>Last Name</td>
      <th>Age</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>Smith</td>
      <td>29</td>
    </tr>
    <tr>
      <td>Jane</td>
      <td>Doe</td>
      <td>26</td>
    </tr>
  </tbody>
</table>
<script>
  tabled.create(document.getElementByTag("table")[0]);
</script>
$ npm install html-tabled
var tabled = require('html-tabled');
tabled.create(document.getElementByTag("table")[0]);
While it's very easy to specify a body for your table, you may want to dynamically populate it using JavaScript. For this, you will need to specify a schema.
At minimum, you will need to provide a <thead></thead> tag in your table.
<table>
  <thead>
    <th>First Name</th> <!-- Column index 0 -->
    <th>Last Name</th>  <!-- Column index 1 -->
    <th>Age</th>        <!-- Column index 2 -->
  </thead>
</table>
tabled will use these tags to create an initial schema for the table. By
default, it will read these tags and convert them to camel case when creating
your schema. Assuming your table looks like the latter, your schema now looks
like this:
table.headers = [ "firstName", "lastName", "age" ]
The table can now be populated.
var tabled = require('html-tabled');
var table  = tabled.create(document.getElementByTag("table")[0], {
  data: [
    { firstName: "John", lastName: "Doe", age: "28" }
  ]
});
You can also update the table and it will adjust automatically.
table.data = [
  { firstName: "Jane", lastName: "Doe", age: "26" }
]
tabledYou can toggle between pages by calling page and specifying a page number.
table.page(1);
You can also filter by a string by calling filter. Filtering is
case-insensitive.
table.filter("john");
Feel free to open a pull-request and contribute to the development of
tabled. Currently, these items are on the roadmap.
The test suite is on Node.js and uses PhantomJS with Mocha.
$ npm install -g
$ npm test
MIT
FAQs
Data-driven HTML tables with vanilla JavaScript
We found that html-tabled demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.