Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@begin/enhance
Advanced tools
Server-side rendering for custom elements with template and slots support
Enhance is a module for rendering custom elements on the server.
It enables a web component workflow that embraces templates and slots.
Enhance works really well with Architect.
npm i @begin/enhance
Author your HTML with custom elements
const html = require('@begin/enhance')()
console.log(html`<hello-world greeting="Well hi!"></hello-world>`)
By default enhance looks for templates in your projects /src/views/templates
directory but you can configure where it should look by passing an options object.
const html = require('@begin/enhance')({ templates: '/components' })
console.log(html`<hello-world greeting="Well hi!"></hello-world>`)
An example template used for Server Side Rendering
// Template
module.exports = function HelloWorldTemplate(state={}, html) {
const { greeting='Hello World' } = state
return html`
<style>
h1 {
color: red;
}
</style>
<h1>${greeting}</h1>
<script type=module>
class HelloWorld extends HTMLElement {
constructor () {
super()
const template = document.getElementById('single-file')
this.attachShadow({ mode: 'open' })
.appendChild(template.content.cloneNode(true))
}
connectedCallback () {
console.log('Why hello there 👋')
}
}
customElements.define('hello-world', HelloWorld)
</script>
`
}
The template added to the server rendered HTML page
// Output
<template id="hello-world-template">
<style>
h1 {
color: red;
}
</style>
<h1>Hello World</h1>
<script type=module>
class HelloWorld extends HTMLElement {
constructor () {
super()
const template = document.getElementById('hello-world-template')
this.attachShadow({ mode: 'open' })
.appendChild(template.content.cloneNode(true))
}
connectedCallback () {
console.log('Why hello there 👋')
}
}
customElements.define('hello-world', HelloWorld)
</script>
</template>
This could also be used to as a static site generator locally. Just console log the output and pipe it to an html page.
FAQs
Server-side rendering for custom elements with template and slots support
The npm package @begin/enhance receives a total of 16 weekly downloads. As such, @begin/enhance popularity was classified as not popular.
We found that @begin/enhance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.