![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
ejs-html
Advanced tools
Changelog
1.1.0
transformer
option to extend semanticsReadme
Embedded JavaScript HTML templates. Another implementation of EJS, focused on run-time performance, HTML syntax checking and outputting minified HTML.
npm install ejs-html --save
let ejs = require('ejs-html')
let html = ejs.render('<input type="text" disabled="<%=disabled%>" value="<%=value%>" />', {
disabled: false,
value: 'hi you'
})
// html = '<input type=text value="hi you">'
This module is inspired by EJS, and is a subset of its syntax, focused on giving HTML first-class support. That is, not all EJS are valid EJS-HTML. Most features listed bellow are possible only with an HTML-aware parser.
Check their excellent site for EJS-specific docs and tutorials.
Strictly speaking, this is not even EJS (details bellow).
The template source is parsed and minified on compile time, so there is no impact on render-time. The minification applies these rules:
<b>Hello you</b>
is transformed to <b>Hello you</b>
<div class="alert">
-> <div class=alert>
<input required>
-> <input required>
<div class=" a b">
-> <div class="a b">
<input required="oh-yeah!">
-> <input required>
<br />
-> <br>
Errors during render-time are mapped back to their original source location (that is, we keep an internal source map)
Attributes like disabled
and checked
are recognized as boolean. So one may write disabled=<%=disabled%>
instead of <%if(disabled){%>disabled<%}%>
, as they must in plain EJS.
This is one point that makes this not EJS compliant. In EJS, anything literal text is outputed as is. In the example above this is not happens: the text disabled=
is not outputed if the local value disabled
is falsy, since ejs-html knows this is a boolean attribute.
Compile the template server-side and export a function to render it in the client-side.
Transformers may be registered to change the parsed elements tree and implement custom semantics.
For example:
// change I tags for EM
var render = ejs.compile('<i>Hi</i> <p><i>Deep</i></p>', {
transformer: function translate(tokens) {
tokens.forEach(token => {
if (token.type === 'element') {
if (token.name === 'i') {
token.name = 'em'
}
translate(token.children)
}
})
}
})
render() // '<em>Hi</em> <p><em>Deep</em></p>'
The following list of features are support other EJS implementations, but not by this one (at least, yet):
FAQs
Embedded JavaScript HTML templates. An implementation of EJS focused on run-time performance, HTML syntax checking, minified HTML output and custom HTML elements.
The npm package ejs-html receives a total of 349 weekly downloads. As such, ejs-html popularity was classified as not popular.
We found that ejs-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.