Skip to content

v5.8.5 - Patch Update

Latest
Compare
Choose a tag to compare
@Javiani Javiani released this 18 Dec 21:12
· 1 commit to main since this release

Change Log

Reusability, Interoperability

Adding html and attributes template tags to use for SPA and SSR cenarios.

Use case

There are sometimes where we want to share functionality between 2 or more applications.
The most obvious ways is to use template literals because it's compatible with node & browser systems.
html, attributes are directives to be used on this context and we want more advanced features on template strings.

import { html, attributes } from 'jails-js/html'

export default function banner ({ attrs = [] }) {
  return html`
    [1, 2, 3].map( n => html`
      <h1 ${ attributes( attrs ) }>
        ${n}
      </h1>
    `)
  `
}

banner({ 
  attrs : [{ title: 'Hello' }] 
})

Output

  <h1 title="Hello">1</h1>
  <h2 title="Hello">2</h2>
  <h3 title="Hello">3</h3>