![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
liquid-node
Advanced tools
LiquidNode 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. Most code has been translated from Ruby to CoffeeScript, with a few adjustments (casing) to make it feel more CoffeeScript/JavaScript-ish.
Besides being written in CoffeeScript (that easily compiles to JavaScript) LiquidNode had to solve a problem which Liquid for Ruby didn't have: the power of Node.js lies in its non-blocking nature and its extensive use of callbacks.
This presents a problem when using sequential/synchronous Liquid-expressions like {{ store.items | count }}
which hide one or multiple blocking SQL-queries.
LiquidNode solves that problem by using Futures and Promises.
The programmer just has to return a Promise
from asynchronous functions -
the designer won't have to care about it.
LiquidNode uses the fast bluebird implementation of Promises/A+ since 0.3.0
.
Liquid is a template engine which was written with very specific requirements:
eval
ing and secure. Liquid templates are made so that users can edit them. You don't want to run code on your server which your users wrote.<ul id="products">
{% for product in products %}
<li>
<h2>{{ product.name }}</h2>
Only {{ product.price | price }}
{{ product.description | prettyprint | paragraph }}
</li>
{% endfor %}
</ul>
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.
Liquid = require "liquid-node"
engine = new Liquid.Engine
# registration of new tags
# see https://github.com/sirlantis/liquid-node/tree/master/src/liquid/tags
engine.registerTag "MyTag", MyTag
# registration of new filters
engine.registerFilters
myFilter: (input) ->
String(input).toUpperCase()
parsePromise = engine.parse "hi {{name}}"
renderPromise = parsePromise
.then (template) ->
template.render name: "tobi"
renderPromise.then (output) ->
console.log output # >> "hi tobi"
or shorter
engine.parse("hi {{name}}")
.then (template) ->
template.render name: "tobi"
.then (output) ->
console.log output # >> "hi tobi"
or even shorter
engine.parseAndRender("hi {{name}}", name: "tobi")
.then (output) ->
console.log output # >> "hi tobi"
LiquidNode uses the promise implementation of bluebird which adheres to the the open standard Promises/A+.
fs = require "fs"
Promise = require "bluebird"
class Server
name: ->
"Falkor"
# A deferred can either be resolved (no error) or rejected (error).
think: ->
Promise.cast(0).delay(1000).then -> 42
# This is an example of how to wait for a Promise:
patientMethod: ->
deepThought = @think()
deepThought.done (answer) -> console.log "The answer is: %s.", answer
deepThought.catch (e) -> console.log "Universe reset: %s.", e
# If you don't want to check, whether an object is a Promise or not
# just use `Promise.cast`. It wrap the object in a Promise if necessary.
unsure: (promiseWannabe) ->
Promise.cast(promiseWannabe)
# You can chain Promises using `promise.then().then().then()...`.
# A `then` will be called with the resolution of the previous `then`.
recipe: ->
gotoStore()
.then (store) -> store.getEggs()
.then (eggs) ->
# or nest the when-calls
eggs.split().then (yolk) -> bakeWith(yolk)
.done (pancake) ->
console.log "Pancake is ready!"
I'm developing this project alongside a different project. I translated a few basic tests from the original Liquid codebase - but there are hundreds of them.
So if you find a bug-fix or have some time to translate further tests I'll be happy to pull them in.
liquid-node
wrapped to run in a browser.LiquidNode is released under the MIT license.
FAQs
Node.js port of Tobias Lütke's Liquid template engine.
The npm package liquid-node receives a total of 589 weekly downloads. As such, liquid-node popularity was classified as not popular.
We found that liquid-node 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.