Skip to content

Commit

Permalink
Feature - Making html, attributes available for server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
Javiani committed Dec 18, 2024
1 parent fdd30c3 commit aae3675
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/jails.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jails.js.map

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@

export const attributes = ( attrs ) => {
const result = Object.entries(attrs)
.map(([key, value]) => {
if( value === '' ) {
return key
}
return `${key}="${value}"`
})
.join(' ')
return result
}

// From
// https://2ality.com/2015/01/template-strings-html.html#comment-2078932192
export default function Html (literalSections, ...substs) {
export const html = (literalSections, ...substs) => {

// Use raw literal sections: we don’t want
// backslashes (\n etc.) to be interpreted
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jails-js",
"version": "5.8.4",
"version": "5.8.5",
"description": "Jails - Elegant and Minimalistic Javascript Application Library",
"module": "./dist/jails.js",
"main": "./dist/jails.js",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { templateConfig, buildtemplates } from './template-system'
import { publish, subscribe } from './utils/pubsub'
import html from '../html'
import { html, attributes } from '../html'
import Element from './element'

const templates = {}
const components = {}

export { html }
export { html, attributes }

export default {

Expand Down

0 comments on commit aae3675

Please sign in to comment.