Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shopify-liquid

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shopify-liquid - npm Package Compare versions

Comparing version 1.2.1 to 1.2.3

dist/liquid.js

6

filters.js

@@ -1,2 +0,3 @@

const strftime = require('strftime').timezone(-(new Date()).getTimezoneOffset());
//const strftime = require('strftime').timezone(-(new Date()).getTimezoneOffset());
const strftime = require('./src/strftime.js');

@@ -10,3 +11,4 @@ module.exports = function(liquid) {

liquid.registerFilter('date', (v, arg) => strftime(arg, v));
//liquid.registerFilter('date', (v, arg) => strftime(arg, v));
liquid.registerFilter('date', (v, arg) => strftime(v, arg));

@@ -13,0 +15,0 @@ liquid.registerFilter('default', (v, arg) => arg || v);

const Scope = require('./src/scope');
const assert = require('assert');
const tokenizer = require('./src/tokenizer.js');
const fs = require('fs');
const Render = require('./src/render.js');
const lexical = require('./src/lexical.js');
const path = require("path");
const fs = require('fs');
const Tag = require('./src/tag.js');

@@ -78,7 +76,3 @@ const Filter = require('./src/filter.js');

handleCache: function(filepath) {
assert(filepath, 'filepath cannot be null');
filepath = path.resolve(this.options.root, filepath);
if (path.extname(filepath) === '') {
filepath += this.options.extname;
}
if (!filepath) throw new Error('filepath cannot be null');

@@ -92,2 +86,7 @@ return this.getTemplate(filepath)

getTemplate: function(filepath) {
filepath = resolvePath(this.options.root, filepath);
if (!filepath.match(/\.\w+$/)) {
filepath += this.options.extname;
}
return new Promise(function(resolve, reject) {

@@ -119,2 +118,15 @@ fs.readFile(filepath, 'utf8', function(err, html) {

function resolvePath(root, path) {
if (path[0] == '/') return path;
var arr = root.split('/').concat(path.split('/'));
var result = [];
arr.forEach(function(slug) {
if (slug == '..') result.pop();
else if (!slug || slug == '.');
else result.push(slug);
});
return '/' + result.join('/');
}
factory.lexical = lexical;

@@ -121,0 +133,0 @@ factory.isTruthy = Expression.isTruthy;

{
"name": "shopify-liquid",
"version": "1.2.1",
"version": "1.2.3",
"description": "Liquid template engine in Node.js (Shopify compliant)",

@@ -28,4 +28,3 @@ "main": "index.js",

"dependencies": {
"any-promise": "^1.3.0",
"strftime": "^0.9.2"
"any-promise": "^1.3.0"
},

@@ -32,0 +31,0 @@ "devDependencies": {

@@ -77,4 +77,5 @@ # shopify-liquid

});
// Note:
// `engine.render(tpl, ctx, opts)` and `engine.renderFile(path, ctx, opts)` also works.
// Note: the below opts also work:
// engine.render(tpl, ctx, opts)
// engine.renderFile(path, ctx, opts)
```

@@ -85,3 +86,7 @@

```javascript
app.engine('liquid', engine.express()); // register liquid engine
// register liquid engine
app.engine('liquid', engine.express({
strict_variables: true, // Default: fasle
strict_filters: true // Default: false
}));
app.set('views', './views'); // specify the views directory

@@ -101,3 +106,3 @@ app.set('view engine', 'liquid'); // set to default

<head>
<script src="shopify-liquid.min.js"></script>
<script src="dist/liquid.min.js"></script>
</head>

@@ -104,0 +109,0 @@ <body>

@@ -1,3 +0,1 @@

const util = require('util');
function TokenizationError(message, input, line) {

@@ -11,7 +9,9 @@ Error.captureStackTrace(this, this.constructor);

}
util.inherits(TokenizationError, Error);
TokenizationError.prototype = Object.create(Error.prototype);
TokenizationError.prototype.constructor = TokenizationError;
function ParseError(message, input, line) {
function ParseError(message, input, line, e) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.originalError = e;

@@ -22,3 +22,4 @@ this.message = message || "";

}
util.inherits(ParseError, Error);
ParseError.prototype = Object.create(Error.prototype);
ParseError.prototype.constructor = ParseError;

@@ -25,0 +26,0 @@ module.exports = {

const Liquid = require('..');
module.exports = function() {
var engine = Liquid({
root: '/root/',
extname: '.html'
});
var engine = Liquid({
root: '/root/',
extname: '.html'
});
function express(filePath, options, callback) {

@@ -10,0 +10,0 @@ fs.readFile(filePath, function(err, content) {

const syntax = require('./syntax.js');
const Exp = require('./expression.js');
const lexical = require('./lexical.js');

@@ -38,3 +37,2 @@

if (lexical.isLiteral(str)) {
var a = lexical.parseLiteral(str);
return lexical.parseLiteral(str);

@@ -41,0 +39,0 @@ }

@@ -25,2 +25,3 @@ const lexical = require('./lexical.js');

this.trigger('start');
var token;
while (!this.stopRequested && (token = this.tokens.shift())) {

@@ -63,3 +64,3 @@ if (this.trigger('token', token)) continue;

} catch (e) {
throw new ParseError(e.message, token.input, token.line);
throw new ParseError(e.message, token.input, token.line, e);
}

@@ -66,0 +67,0 @@ }

@@ -1,4 +0,2 @@

const error = require('./error.js');
const Exp = require('./expression.js');
const assert = require('assert');
const Promise = require('any-promise');

@@ -9,3 +7,3 @@

renderTemplates: function(templates, scope, opts) {
assert(scope, 'unable to evalTemplates: scope undefined');
if(!scope) throw new Error('unable to evalTemplates: scope undefined');
opts = opts || {};

@@ -94,3 +92,3 @@ opts.strict_filters = opts.strict_filters || false;

evalOutput: function(template, scope, opts) {
assert(scope, 'unable to evalOutput: scope undefined');
if(!scope) throw new Error('unable to evalOutput: scope undefined');
var val = Exp.evalExp(template.initial, scope);

@@ -97,0 +95,0 @@ template.filters.some(filter => {

@@ -1,3 +0,1 @@

const lexical = require('./lexical.js');
var Scope = {

@@ -4,0 +2,0 @@ safeGet: function(str) {

const lexical = require('./lexical.js');
const Promise = require('any-promise');
const Exp = require('./expression.js');
const TokenizationError = require('./error.js').TokenizationError;
function hash(markup, scope) {
var obj = {};
var obj = {}, match;
lexical.hashCapture.lastIndex = 0;

@@ -9,0 +8,0 @@ while (match = lexical.hashCapture.exec(markup)) {

var Liquid = require('..');
var lexical = Liquid.lexical;
var Promise = require('any-promise');
var lexical = Liquid.lexical;
var re = new RegExp(`(${lexical.identifier.source})\\s*=(.*)`);

@@ -5,0 +5,0 @@

var Liquid = require('..');
var lexical = Liquid.lexical;

@@ -4,0 +3,0 @@ module.exports = function(liquid) {

@@ -1,5 +0,1 @@

var Liquid = require('..');
var lexical = Liquid.lexical;
var re = new RegExp(`(${lexical.identifier.source})`);
module.exports = function(liquid) {

@@ -6,0 +2,0 @@

const Liquid = require('..');
const lexical = Liquid.lexical;
const error = Liquid.error;

@@ -5,0 +4,0 @@ module.exports = function(liquid) {

var Liquid = require('..');
var lexical = Liquid.lexical;

@@ -4,0 +3,0 @@ module.exports = function(liquid) {

var Liquid = require('..');
var Promise = require('any-promise');
var lexical = Liquid.lexical;

@@ -4,0 +3,0 @@ var withRE = new RegExp(`with\\s+(${lexical.value.source})`);

var Liquid = require('..');
var Promise = require('any-promise');
var lexical = Liquid.lexical;
var withRE = new RegExp(`with\\s+(${lexical.value.source})`);

@@ -38,10 +37,2 @@ module.exports = function(liquid) {

});
// var tpl = liquid.handleCache(layout);
//
// scope.push({});
// liquid.renderer.renderTemplates(this.tpls, scope); // what's the point of this line?
// var html = liquid.renderer.renderTemplates(tpl, scope);
// scope.pop();
// return html;
}

@@ -79,8 +70,2 @@ });

return promise;
// if(html === undefined){
// html = liquid.renderer.renderTemplates(this.tpls, scope);
// }
// scope.set(`_liquid.blocks.${this.block}`, html);
// return html;
}

@@ -87,0 +72,0 @@ });

@@ -1,5 +0,2 @@

var Liquid = require('..');
var Promise = require('any-promise');
var lexical = Liquid.lexical;
var re = new RegExp(`(${lexical.identifier.source})`);

@@ -6,0 +3,0 @@ module.exports = function(liquid) {

@@ -33,5 +33,3 @@ var Liquid = require('..');

var html = '<table>',
promiseChain = Promise.resolve(''); // create an empty promise to begin the chain
length = collection.length;
var html = '<table>';
var offset = hash.offset || 0;

@@ -38,0 +36,0 @@ var limit = (hash.limit === undefined) ? collection.length : hash.limit;

var Liquid = require('..');
var lexical = Liquid.lexical;

@@ -4,0 +3,0 @@ module.exports = function(liquid) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc