Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Jyt is a concise, lightweight JavaScript-based templating engine for HTML (or XML for that matter). Because it is JavaScript-based, there is no extra parser/lexer needed for either a JavaScript-based server (like Node), or the browser. With its extensive shorthand, small amounts of code expand to large pieces of HTML. Its plugin system allows you to leverage plugins that others have written that reduce large, common pieces of markup to a few characters of code.
Installation is simple. From your command line enter the following:
npm install jyt --save
Then in your code you can just use it like any other library:
var jyt = require('jyt');
console.log(jyt.render(jyt.div('hello, world')));
// output: <div>hello, world</div>
You don't need the jyt. prefix for HTML functions. There are two ways to remove the prefix and just reference the HTML functions by themselves.
Option 1 - Attach to Globals
This is not and ideal solution, but you can attach to the node.js global object:
jyt.addShortcutsToScope(global);
Option 2 - Dependency Injection
The more ideal solution and what Jyt was built for is to utilize dependency injection. Using Pancakes or another dependency injector, your template could look something like this:
function generateHtml(div, span, a, img) {
return div({ 'class': 'wrapper' },
span('hello, world'),
div({ 'class': 'inner' },
a({
href: '/blah',
title: 'click here'
}, 'Some Link'),
img({ 'class': 'logo', src: '/something.jpg' })
)
);
}
I personally prefer this version of markup much more than actual HTML.
For now plugins are really simple. They are just arbitrary functions that will be added to any scope when you call jyt.addShortcutsToScope(). There are only two common ones built in core:
There are child repos built on top of this in order to provide specific syntax for a particular technology. The biggest one right now is Jangular. Other ones are in the works.
FAQs
JavaScript Your Templates
We found that jyt 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.