Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
breezeblock
Advanced tools
An experimental templating language for JS that can compile directly to DOM.
Compatible with all modern browsers and IE9+.
BreezeBlock templates can compile to a number of different formats:
The HTML format simply outputs a string of markup when the template is rendered. The Precompiled HTML generator format outputs the template as JavaScript, preventing unnecessary overhead from parsing the template and traversing its AST. This feature is implemented in many templating engines. The DOM generator is unique: the template is output as JavaScript that directly generates DOM using createElement
and createTextNode
.
<!-- This: -->
<img src={{foo}}>
<!-- becomes this: -->
<script>
function template(document, elem, scope) {
var elem1 = document.createElement("img");
elem1.setAttribute("src".toLowerCase(), scope["foo"]);
elem.appendChild(elem1);
elem.appendChild(document.createTextNode("\n"));
}
</script>
innerHTML
is never used and markup is never concatenated with user-provided data, there is virtually no risk of XSS.document
object to the DOM generation function.Write HTML as you normally would. Self-closing tags that are not void elements must use a closing slash (<foo />
).
<div>
Text nodes can be included inline
<br>
<!-- HTML comments are welcome -->
<b class="really-bold">Mix and match tags</b>
<my-custom-element />
</div>
Attribute names and values may be variable:
<div {{foo}}="bar"></div>
<div data-foo={{bar}}></div>
<!--
`fieldChecked` and `fieldReadonly` should contain "checked" and "readonly respectively"
-->
<input type="text" {{fieldChecked}} {{fieldReadonly}}>
<!-- Attributes may be conditional -->
<img src="foo.jpg" alt="" {% if imageTitle %}title={{imageTitle}}{%/ if %}>
<input type="checkbox" {% if checkboxChecked %}checked{%/ if %}>
Node contents can be variable:
<div>Here is my {{value}}</div>
<aside>{{value}}</aside>
Expressions can use dot notation and subscripts:
<img src={{images[index].src}} alt={{images[index]["alt"]}}>
<img src={{images[0].src}} alt={{images[0]["alt"]}}>
{% loop ... %}
{{{foo}}}
)<img src="{{cdn}}/img/{{imagePath}}">
FAQs
A flexible JS-based templating engine
The npm package breezeblock receives a total of 10 weekly downloads. As such, breezeblock popularity was classified as not popular.
We found that breezeblock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.