liquid-to-handlebars

Node.js lib for converting liquid templates to handlebars templates. Whipped this up as a quick and dirty, preliminary step to extracting HTML components from Bootstrap's docs, in a way that makes them actually reusable.

liquid-to-handlebars

Node.js lib for converting liquid templates to handlebars templates. Whipped this up as a quick and dirty, preliminary step to extracting HTML components from Bootstrap's docs, in a way that makes them actually reusable.

Install with npm:

npm i liquid-to-handlebars --save-dev
npm test

Don't expect miracles. For now, coverage is limited to converting Bootstrap's docs templates to handlebars.

var convert = require('liquid-to-handlebars');
 
// pass a string of HTML with liquid 
console.log(convert('{liquid}'));

So replacement patterns for number of tags and filters have not been implemented. Here is the replacement pattern for converting {{content}} liquid variables to {{> body }} handlebars partials:

{
  pattern: tag.makeVariable('content', {matter: ''}),
  replacementfunction (matchstr) {
    return '{{> body }}';
  }
}

Feel free to do a PR to add replacement patterns.

To test drive the example:

git clone https://github.com/jonschlinkert/liquid-to-handlebars.git

Then cd into the project and run npm install.

Next, clone Bootstrap

Don't use Bower, use git clone since we need to actual HTML docs:

git clone https://github.com/twbs/bootstrap.git "vendor/bootstrap"

Next, run

node examples/example

Converted files will be written to the ./results directory.

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Jon Schlinkert

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 16, 2014.