Пример #1
0
test("Handlebars embedded in an attribute with other content surrounding it", function() {
  let t = 'some <a href="http://{{link}}/">content</a> done';
  astEqual(t, b.program([
    b.text("some "),
    b.element("a", [
      b.attr("href", b.concat([
        b.string("http://"),
        b.path('link'),
        b.string("/")
      ]))
    ], [], [
      b.text("content")
    ]),
    b.text(" done")
  ]));
});
Пример #2
0
test("A more complete embedding example", function() {
  let t = "{{embed}} {{some 'content'}} " +
          "<div class='{{foo}} {{bind-class isEnabled truthy='enabled'}}'>{{ content }}</div>" +
          " {{more 'embed'}}";
  astEqual(t, b.program([
    b.mustache(b.path('embed')),
    b.text(' '),
    b.mustache(b.path('some'), [b.string('content')]),
    b.text(' '),
    b.element("div", [
      b.attr("class", b.concat([
        b.mustache('foo'),
        b.text(' '),
        b.mustache('bind-class', [b.path('isEnabled')], b.hash([b.pair('truthy', b.string('enabled'))]))
      ]))
    ], [], [
      b.mustache(b.path('content'))
    ]),
    b.text(' '),
    b.mustache(b.path('more'), [b.string('embed')])
  ]));
});
Пример #3
0
test("Tokenizer: MustacheStatement encountered in afterAttributeValueQuoted state", function() {
  let t = "<input foo='1'{{bar}}>";
  astEqual(t, b.program([
    b.element('input', [ b.attr('foo', b.text('1')) ], [ b.elementModifier(b.path('bar')) ])
  ]));
});
Пример #4
0
test("Handlebars embedded in an attribute of a self-closing tag (unqouted)", function() {
  let t = '<input value={{foo}}/>';
  astEqual(t, b.program([
    b.element("input", [ b.attr("value", b.mustache(b.path('foo'))) ], [], []),
  ]));
});