mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 06:50:47 -07:00
render undefined to ''
This commit is contained in:
@@ -102,9 +102,7 @@ Footer
|
|||||||
* It's possible to define multiple blocks.
|
* It's possible to define multiple blocks.
|
||||||
* block name is optional when there's only one block.
|
* block name is optional when there's only one block.
|
||||||
|
|
||||||
## Extension
|
## Register Filters
|
||||||
|
|
||||||
Register Filters:
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Usage: {{ name | uppper }}
|
// Usage: {{ name | uppper }}
|
||||||
@@ -115,7 +113,7 @@ engine.registerFilter('upper', function(v){
|
|||||||
|
|
||||||
> See existing filter implementations: <https://github.com/harttle/shopify-liquid/blob/master/filters.js>
|
> See existing filter implementations: <https://github.com/harttle/shopify-liquid/blob/master/filters.js>
|
||||||
|
|
||||||
Register Tags:
|
## Register Tags
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Usage: {% upper name%}
|
// Usage: {% upper name%}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shopify-liquid",
|
"name": "shopify-liquid",
|
||||||
"version": "1.1.7",
|
"version": "1.1.8",
|
||||||
"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
-1
@@ -21,7 +21,7 @@ var render = {
|
|||||||
break;
|
break;
|
||||||
case 'output':
|
case 'output':
|
||||||
var val = this.evalOutput(template, scope);
|
var val = this.evalOutput(template, scope);
|
||||||
html += stringify(val);
|
html += val === undefined ? '' : stringify(val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return html;
|
return html;
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ describe('liquid', function() {
|
|||||||
it('should output array', function() {
|
it('should output array', function() {
|
||||||
engine.parseAndRender('{{arr}}', ctx).should.equal('[-2,"a"]');
|
engine.parseAndRender('{{arr}}', ctx).should.equal('[-2,"a"]');
|
||||||
});
|
});
|
||||||
|
it('should output undefined to empty', function() {
|
||||||
|
engine.parseAndRender('foo{{zzz}}bar', ctx).should.equal('foobar');
|
||||||
|
});
|
||||||
it('should parse html', function() {
|
it('should parse html', function() {
|
||||||
(function() {
|
(function() {
|
||||||
engine.parse('{{obj}}');
|
engine.parse('{{obj}}');
|
||||||
|
|||||||
Reference in New Issue
Block a user