txl

1.0.0 • Public • Published

SYNOPSIS

All your html templating needs in under 10 lines of JS.

USAGE

BASICS

The Template function takes a string and returns a function that takes your template "locals".

const Template = require('templates')
const t = Template('<h1>${name}</h1>')

t({ nane: 'Danzig' }) // t() can be reused

ITERATION

index.js

const Template = require('templates')
const fs = require('fs')

const t = Template(fs.readFileSync('./template'))

t({ list: [1,2,3] })
<ul>
  ${ list.map(n => `<li>${n}</li>`).join('') }
</ul>

MIXINS

index.js

const Template = require('templates')
const fs = require('fs')

const t = Template(fs.readFileSync('./index.template'))
const m = Template(fs.readFileSync('./mixin.template'))

t({ names: ['Glen', 'Henry'] li: m })

index.template

<ul>
  ${ list.map(name => li({ name })).join('') }
</ul>

mixin.template

<li class="name">${name}</li>

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    10
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    10

Package Sidebar

Install

npm i txl

Weekly Downloads

9

Version

1.0.0

License

MIT

Last publish

Collaborators

  • hij1nx