Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

ragtag

0.0.1 • Public • Published

Ragtag

Minimal templating using ES6 tagged template literals.

XO code style

Install

npm install ragtag

Usage

const ragtag = require('ragtag');
 
const title = '<h1>My great website</h1>';
 
const links = [
  {
    href: '/',
    text: 'Home'
  },
  {
    href: '/about',
    text: 'About'
  },
  {
    href: '/contact',
    text: 'Contact'
  }
];
 
const html = ragtag`
  <header>
    ${title}
  </header>
  <nav>
    <ul>
      ${links.map(link => ragtag`
        <li><a href='${link.href}'>${link.text}</a></li>
      `)}
    </ul>
  </nav>
`;
 
console.log(html);
 
<header>
  <h1>My great website</h1>
</header>
<nav>
  <ul>
    <li><a href='/'>Home</a></li>
    <li><a href='/about'>About</a></li>
    <li><a href='/contact'>Contact</a></li>
  </ul>
</nav>

Keywords

none

install

npm i ragtag

Downloadsweekly downloads

1

version

0.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability