Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
liquid-node
Advanced tools
LiquidNode is a port of the Liquid template engine (originally written in Ruby) to Node.js. It uses Promises to support non-blocking, asynchronous variables/filters/blocks. Most code has been translated from Ruby to CoffeeScript, with a few adjustments (casing) to make it feel more Coffee-/JavaScripty.
The power of Node.js lies in its non-blocking nature. This presents a problem when using expressions like {{ store.items | count }}
which may hide a blocking SQL-query.
LiquidNode tries to solve that problem by using Futures and Promises. The programmer must return Promises from asynchronous functions - designers don't have to care about it.
I started with the futures package as an implementation of Promises but it didn't chain as nicely as I had hoped for. So here is LiquidNode's custom Promise implementation:
fs = require "fs"
{async} = require "liquid-node"
class Server
name: ->
"Falkor"
# A deferred can either be resolved (no error) or rejected (error).
think: ->
async.promise (deferred) ->
later = -> deferred.resolve(42)
setTimeout(later, 1000)
# This is an example of how to wait for a Promise:
patientMethod: ->
deepThought = @think()
deepThought
.done (answer) -> console.log "The answer is: %s.", answer
.fail (e) -> console.log "Universe reset: %s.", e
.always (e) -> console.log "Look on the bright side of life."
# By the way: the left-hand side of async.promise returns a
# read-only view (Promise) to the Deferred. This means an
# Illuminati can't interfere with it on this side of the
# Promise.
#
# deepThought.resolve(23) isn't available.
# For node-ish callbacks you can use `deferred.node`. This
# will automatically resolve/reject based on the first argument.
accounts: ->
async.promise (deferred) ->
fs.readFile "/etc/passwd", "utf-8", deferred.node
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 is a template engine which was written with very specific requirements:
<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.Template class. For standard use you can just pass it the content of a file and call render with a parameters hash.
Liquid = require "liquid-node"
template = Liquid.Template.parse("hi {{name}}") # Parses and compiles the template
promise = template.render 'name': 'tobi' # => [Promise Object]
promise.done console.log # >> "hi tobi"
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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
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.