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.
This is a port of the original Liquid template engine from Ruby to Node.js. It uses Promises to support non-blocking/asynchronous variables, filters, and blocks.
<ul id="products">
{% for product in products %}
<li>
<h2>{{ product.name }}</h2>
Only {{ product.price | price }}
{{ product.description | prettyprint | paragraph }}
</li>
{% endfor %}
</ul>
npm install liquid
Liquid supports a very simple API based around the Liquid.Engine class. For standard use you can just pass it the content of a file and call render with an object.
const Liquid = require('liquid')
const engine = new Liquid.Engine()
engine
.parse('hi {{name}}')
.then(template => template.render({ name: 'tobi' }))
.then(result => console.log(result))
// or
engine
.parseAndRender('hi {{name}}', { name: 'tobi' })
.then(result => console.log(result))
app.get((req, res, next) => {
engine
.parseAndRender('hi {{name}}', { name: 'tobi' })
.nodeify((err, result) => {
if (err) {
res.end('ERROR: ' + err)
} else {
res.end(result)
}
})
})
engine.registerFilters({
myFilter: input => {
return String(input).toUpperCase()
}
})
Take a look at the existing tags to see how to implement them.
class MyTag extends Liquid.Tag {
render () {
return 'hello world'
}
}
engine.registerTag('MyTag', MyTag)
npm test
liquidjs
on npm) is another actively maintained Liquid parser and render for Node.jsliquid-node
wrapped to run in a browser.Thanks goes to these wonderful people (emoji key):
Marcel Jackwerth 💻 📖 | Tony C. Heupel 💻 | Chen Yangjian 💻 | Henri Bergius 💻 | Sam Tiffin 💻 | Kris Ciccarello 💻 | Cory Reed 💻 💡 📖 |
Sebastian Seilund 💻 | Rob Loach 💻 | Sarah Schneider 💻 | Zeke Sikelianos 💻 📖 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Node.js port of the Liquid template engine
We found that liquid 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.