mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-02 16:45:14 -07:00
err.file for #renderFile()
This commit is contained in:
@@ -42,8 +42,14 @@ var _engine = {
|
|||||||
return this.render(tpl, ctx);
|
return this.render(tpl, ctx);
|
||||||
},
|
},
|
||||||
renderFile: function(filepath, ctx) {
|
renderFile: function(filepath, ctx) {
|
||||||
var tpl = this.handleCache(filepath);
|
try{
|
||||||
return this.render(tpl, ctx);
|
var tpl = this.handleCache(filepath);
|
||||||
|
return this.render(tpl, ctx);
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
e.file = filepath;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
evalOutput: function(str, scope) {
|
evalOutput: function(str, scope) {
|
||||||
var tpl = this.parser.parseOutput(str.trim());
|
var tpl = this.parser.parseOutput(str.trim());
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shopify-liquid",
|
"name": "shopify-liquid",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"description": "A Shopify Liquid Implementation in Node.js",
|
"description": "A Shopify Liquid Implementation in Node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var chai = require("chai");
|
var chai = require("chai");
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
var engine = require('..')(), ctx;
|
var engine = require('..')(), ctx;
|
||||||
|
const mock = require('mock-fs');
|
||||||
|
|
||||||
function test(func, cb){
|
function test(func, cb){
|
||||||
try{
|
try{
|
||||||
@@ -34,6 +35,19 @@ describe('error', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw correct error info for files', function() {
|
||||||
|
mock({
|
||||||
|
"/foo.html": '<html>\n<head>\n\n{% raw %}\n\n'
|
||||||
|
});
|
||||||
|
test(function(){
|
||||||
|
engine.renderFile('/foo.html', {});
|
||||||
|
}, function(err){
|
||||||
|
expect(err.input).to.equal('{% raw %}');
|
||||||
|
expect(err.line).to.equal(4);
|
||||||
|
expect(err.file).to.equal('/foo.html');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw ParseError when filter not exist', function() {
|
it('should throw ParseError when filter not exist', function() {
|
||||||
test(function(){
|
test(function(){
|
||||||
engine.parseAndRender('{{ a | xz }}', {});
|
engine.parseAndRender('{{ a | xz }}', {});
|
||||||
|
|||||||
Reference in New Issue
Block a user