Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

liquid.js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liquid.js

JavaScript port of Tobias Luetke's Liquid template engine.

latest
Source
npmnpm
Version
1.3.2
Version published
Maintainers
1
Created
Source

h1. Liquid.js

h2. General

This is a complete port of "Liquid":http://www.liquidmarkup.org/ from Ruby to JavaScript. Any template that Ruby Liquid can compile and render, Liquid.js should too.

This tries to be javascript framework agnostic (i.e. doesn't use jQuery nor Prototype). This adds a little extra code as it implements its own helpers like clear, first, last on Array, and a Class OOP implementation; this tradeoff is made to allow the code to be portable across many systems.

Liquid.js does not use eval or with, so it's pretty clean and really safe.

h2. Installation

The current version of the library is checked into the dist directory.

To re-build from source, follow these steps:

Clone the repository somewhere locally and go into the folder; i.e. @git clone git@github.com:/mattmccray/liquid.js.git@.

Run @bundle install@ to install the necessary Gemfiles.

Compile the JavaScript files with the default rake task; i.e. @bundle exec rake@.

Copy the distribution files to your desired location; i.e. @cp dist/liquid*.js ~/projects/my_project/public/javascripts/@.

h2. Differences

Ranges. JavaScript doesn't really have Ranges like Ruby does. So when Liquid.js comes across a range "(1..5)", it creates an Array with the values 1 through 5. In addition ranges like (a..z) should work.

'replace' and 'replace_first' filters build RegExps from the input, so you can actually define a regexp to use in your replacement.

'include' tag. By default, this will return a Liquid error (but not an exception). To use the 'include' tag, you'll need to implement your own 'filesystem' support. Which, in Liquid.js, just means you override the Liquid.readTemplateFile function to suit your own needs. Here's an example:



h2. Known Issues

Known to work in Safari 3.1+ and FireFox 3+.

IE 7: passes tests but needs more actual usage testing

h2. References:

h2. Development

Fork the project on github.

Follow the installation steps with your repository.

Load the test/liquid-tests.html file to execute the tests; i.e. in a web browser load 'file:///home/username/projects/liquid.js/test/liquid-tests.html'.

Load the test/liquid-console.html to debug specific templates or test scenarios; i.e. in a web browser load 'file:///home/username/projects/liquid.js/test/liquid-tests.html'.

h3. Todo

  • Add Rhino support for console-based testing?
  • Move the Class OOP support (that replaced Prototype) into Liquid.Class so it won't conflict with other implementations.
  • Look at the Object extensions and consider making a Liquid.Hash class similar to Prototype.
  • Look into making into a gem or something that has the auto-compiled JS file in the workflow somewhere.

Keywords

Liquid

FAQs

Package last updated on 27 Apr 2015

Did you know?

Socket

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.

Install

Related posts