mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
raw and comment
This commit is contained in:
@@ -27,12 +27,6 @@ describe('tag', function() {
|
||||
}).to.throw(/tag foo not found/);
|
||||
});
|
||||
|
||||
it('should throw when render method not defined', function() {
|
||||
expect(function() {
|
||||
tag.register('foo', {});
|
||||
}).to.throw(/expect foo.render to be a function/);
|
||||
});
|
||||
|
||||
it('should register simple tag', function() {
|
||||
expect(
|
||||
function() {
|
||||
|
||||
@@ -34,6 +34,18 @@ describe('tags', function() {
|
||||
test('{% assign foo="a b" | capitalize | split: " " | first %}{{foo}}', 'A');
|
||||
});
|
||||
|
||||
it('should support raw', function() {
|
||||
testThrow('{% raw%}', /{% raw%} not closed/);
|
||||
test('{% raw %}{{ 5 | plus: 6 }}{% endraw %} is equal to 11.', '{{ 5 | plus: 6 }} is equal to 11.');
|
||||
test('{% raw %}\n{{ foo}} \n{% endraw %}', '\n{{ foo}} \n');
|
||||
});
|
||||
|
||||
it('should support comment', function() {
|
||||
testThrow('{% comment %}{% raw%}', /{% comment %} not closed/);
|
||||
test('My name is {% comment %}super{% endcomment %} Shopify.', 'My name is Shopify.');
|
||||
test('{% comment %}\n{{ foo}} \n{% endcomment %}', '');
|
||||
});
|
||||
|
||||
it('should support case', function() {
|
||||
testThrow('{% case "foo"%}', /{% case "foo"%} not closed/);
|
||||
test('{% case "foo"%}' +
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var chai = require("chai");
|
||||
var should = chai.should();
|
||||
var expect = chai.expect;
|
||||
|
||||
var tokenizer = require('../tokenizer.js');
|
||||
|
||||
@@ -39,4 +40,13 @@ describe('tokenizer', function() {
|
||||
tokens[1].value.should.equal('bar');
|
||||
tokens[2].value.should.equal('foo');
|
||||
});
|
||||
it('should keep white spaces and newlines', function(){
|
||||
var html = '{{foo}}\n{%bar %} \n {{alice}}';
|
||||
var tokens = tokenizer.parse(html);
|
||||
expect(tokens.length).to.equal(5);
|
||||
expect(tokens[1].type).to.equal('html');
|
||||
expect(tokens[1].raw).to.equal('\n');
|
||||
expect(tokens[3].type).to.equal('html');
|
||||
expect(tokens[3].raw).to.equal(' \n ');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user