Esempio n. 1
0
test("Stripping - programs", function() {
  let t = "{{#wat~}} foo {{else}}{{/wat}}";
  astEqual(t, b.program([
    b.block(b.path('wat'), [], b.hash(), b.program([
      b.text('foo ')
    ]), b.program())
  ]));

  t = "{{#wat}} foo {{~else}}{{/wat}}";
  astEqual(t, b.program([
    b.block(b.path('wat'), [], b.hash(), b.program([
      b.text(' foo')
    ]), b.program())
  ]));

  t = "{{#wat}}{{else~}} foo {{/wat}}";
  astEqual(t, b.program([
    b.block(b.path('wat'), [], b.hash(), b.program(), b.program([
      b.text('foo ')
    ]))
  ]));

  t = "{{#wat}}{{else}} foo {{~/wat}}";
  astEqual(t, b.program([
    b.block(b.path('wat'), [], b.hash(), b.program(), b.program([
      b.text(' foo')
    ]))
  ]));
});
Esempio n. 2
0
test("an HTML comment", function() {
  let t = 'before <!-- some comment --> after';
  astEqual(t, b.program([
    b.text("before "),
    b.comment(" some comment "),
    b.text(" after")
  ]));
});
Esempio n. 3
0
test("a piece of content with HTML", function() {
  let t = 'some <div>content</div> done';
  astEqual(t, b.program([
    b.text("some "),
    b.element("div", [], [], [
      b.text("content")
    ]),
    b.text(" done")
  ]));
});
Esempio n. 4
0
test("a piece of Handlebars with HTML", function() {
  let t = 'some <div>{{content}}</div> done';
  astEqual(t, b.program([
    b.text("some "),
    b.element("div", [], [], [
      b.mustache(b.path('content'))
    ]),
    b.text(" done")
  ]));
});
Esempio n. 5
0
test("Handlebars embedded in an attribute (unquoted)", function() {
  let t = 'some <div class={{foo}}>content</div> done';
  astEqual(t, b.program([
    b.text("some "),
    b.element("div", [ b.attr("class", b.mustache(b.path('foo'))) ], [], [
      b.text("content")
    ]),
    b.text(" done")
  ]));
});
Esempio n. 6
0
test("Element modifiers", function() {
  let t = "<p {{action 'boom'}} class='bar'>Some content</p>";
  astEqual(t, b.program([
    b.element('p', [ b.attr('class', b.text('bar')) ], [
      b.elementModifier(b.path('action'), [b.string('boom')])
    ], [
      b.text('Some content')
    ])
  ]));
});
Esempio n. 7
0
test("allow an AST with mustaches to be passed", function() {
  let ast = parse(handlebarsParse("<h1>some</h1> ast {{foo}}"));

  astEqual(ast, b.program([
    b.element("h1", [], [], [
      b.text("some")
    ]),
    b.text(" ast "),
    b.mustache(b.path('foo'))
  ]));
});
Esempio n. 8
0
test("Handlebars embedded in an attribute (sexprs)", function() {
  let t = 'some <div class="{{foo (foo "abc")}}">content</div> done';
  astEqual(t, b.program([
    b.text("some "),
    b.element("div", [
      b.attr("class", b.concat([ b.mustache(b.path('foo'), [ b.sexpr(b.path('foo'), [ b.string('abc') ]) ]) ]))
    ], [], [
      b.text("content")
    ]),
    b.text(" done")
  ]));
});
Esempio n. 9
0
test("Stripping - blocks", function() {
  let t = "foo {{~#wat}}{{/wat}} bar";
  astEqual(t, b.program([
    b.text('foo'),
    b.block(b.path('wat'), [], b.hash(), b.program()),
    b.text(' bar')
  ]));

  t = "foo {{#wat}}{{/wat~}} bar";
  astEqual(t, b.program([
    b.text('foo '),
    b.block(b.path('wat'), [], b.hash(), b.program()),
    b.text('bar')
  ]));
});
Esempio n. 10
0
test("Stripping - mustaches", function() {
  let t = "foo {{~content}} bar";
  astEqual(t, b.program([
    b.text('foo'),
    b.mustache(b.path('content')),
    b.text(' bar')
  ]));

  t = "foo {{content~}} bar";
  astEqual(t, b.program([
    b.text('foo '),
    b.mustache(b.path('content')),
    b.text('bar')
  ]));
});