Proposed: Standards-compliant polyfill for HTML <template> #4
ptrdo
started this conversation in
Show and tell
Replies: 1 comment
-
LGTM! What do others think? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Gist
When displaying information in an HTML page, it is often useful for a script to loop over data to extract its values and embed them into repeatable markup patterns. This sort of routine can quickly populate the many rows and columns of a complex
table
of data and is convenient for rendering pedestrian page elements likemenu
andselect-option
lists.Of course, this is nothing new and is fundamental to JavaScript frameworks, but standard HTML also provides for this with the
template
element. Even more, HTML has long supported a particular set ofmicrodata
attributes designed to make such rendered information more understandable to the machine reading done by search engine crawlers and the like.Background
About ten years ago (2013), the Institute for Disease Modeling (IDM) at the Gates Foundation needed to build a data-intensive web application. One requirement of this design was that it be low-dependency. Part of this requirement was due to the sensitive nature of the work, especially an expressed need to minimize potential exploits into high-performance computing clusters (this web application was essentially an interface into that). However, there were also few developers on the project, and its development was slow-moving, so adherence to standards was more attractive than keeping up to date with myriad libraries and frameworks.
The result was a custom-built polyfill to the HTML
template
standard. Even more, themicrodata
methodology was integrated to standardize implementation while also rendering smartly organized pages conducive to data structures. When executed according to design, a rendered page in the cache could emulate a database of data without necessitating a roundtrip to the database.Library
The initial release of
microdata-template
was in January 2018, but by then, it had been in regular use for several years. This was when ES6 was in flux and bundlers were gaining popularity, so publishing an open-source library made sense to formalize its evolution.At times, there were hundreds of downloads (NPM) per week, but no efforts were made to publicize the library. At most, there were three contributors (mostly private). The web application for which this library was built is still in active service but is sunsetting. Neither IDM nor the Gates Foundation has any claim or ownership of the code, though backward compatibility should be maintained for them and any other users.
Code
Repository
https://github.com/ptrdo/microdata-template
Package
https://www.npmjs.com/package/microdata-template
Example use:
https://drive.google.com/drive/folders/1YsYtel-XrvNhxN8DiW6vhWWMYLuZ2WVf?usp=sharing
Summary
This code has been a reliable workhorse and has negated the need for frameworks. In fact, a web application built with this code is alive and well after ten years, and that is saying something.
Beta Was this translation helpful? Give feedback.
All reactions