An uncomplicated user interface library for cloning semantic templates

Fork me on GitHub

Hello World Bookstore Example

The code below is a bare bones, standalone web page with the all the CSS and JavaScript to demonstrate dna-engine in action.

Each call to dna.clone() creates a new element from the book template and appends the element to the books element.

Bookstore Code


            <!doctype html>
               <meta charset=utf-8>
               <link rel=stylesheet href=https://cdn.jsdelivr.net/npm/dna-engine@3/dist/dna-engine.css>
               <script src=https://cdn.jsdelivr.net/npm/dna-engine@3/dist/dna-engine.min.js></script>
                  body     { font-family: system-ui, sans-serif; margin: 30px; }
                  .books   { width: 250px; }
                  .book    { background-color: gold; padding: 10px; margin-bottom: 15px; }
                  .book h2 { font-size: 1.1rem; margin: 0px; }

               <section class=books>
                  <div id=book class=dna-template>
                     Author: <cite>~~author~~</cite>

               const books = [
                  { title: 'The DOM',      author: 'Jan' },
                  { title: 'Howdy HTML5',  author: 'Ed' },
                  { title: 'Styling CSS3', author: 'Abby' },
               dna.clone('book', books);

Bookstore Web Page


Bookstore on jsFiddle

Experiment with the code at:

Questions and comments

Tweet your question or comment with #dna-engine or submit an issue on GitHub.