Example #1
0
function render(template: Template, self: any) {
  let result: RenderResult;
  env.begin();
  let templateIterator = template.renderLayout({ env, self: new UpdatableReference(self), cursor: { element: root, nextSibling: null }, dynamicScope: new TestDynamicScope() });
  let iteratorResult: IteratorResult<RenderResult>;
  do {
    iteratorResult = templateIterator.next() as IteratorResult<RenderResult>;
  } while (!iteratorResult.done);

  result = iteratorResult.value;
  env.commit();
  return result;
}
Example #2
0
    test("HTML tags re-rendered", assert => {
      let template = compile("<h1>hello!</h1><div>content</div>");
      let result = render(template, {});

      let oldFirstChild = root.firstChild;

      env.begin();
      result.rerender();
      env.commit();

      assert.strictEqual(root.firstChild, oldFirstChild);
      equalTokens(root, "<h1>hello!</h1><div>content</div>");
    });
Example #3
0
function render<T>(template: Template<T>, self: any) {
  let result;
  env.begin();
  let templateIterator = template.render(new UpdatableReference(self), root, new TestDynamicScope());

  do {
    result = templateIterator.next();
  } while (!result.done);

  result = result.value;
  env.commit();
  return result;
}
Example #4
0
function render<T>(template: Template<T>, context={}) {
  self = new UpdatableReference(context);
  env.begin();
  let templateIterator = template.render(self, root, new TestDynamicScope());

  do {
    result = templateIterator.next();
  } while (!result.done);

  result = result.value;
  env.commit();
  return result;
}
Example #5
0
function render<T>(template: Template<T>, context = {}, view: PathReference<Opaque> = null) {
  self = new UpdatableReference(context);
  env.begin();
  let templateIterator = template.render(self, root, new TestDynamicScope());

  do {
    result = templateIterator.next();
  } while (!result.done);

  result = result.value;
  env.commit();
  assertInvariants(result);
  return result;
}
Example #6
0
function render(template: Template, context = {}) {
  self = new UpdatableReference(context);
  env.begin();
  let cursor = { element: root, nextSibling: null };
  let templateIterator = template.renderLayout({ env, self, cursor, dynamicScope: new TestDynamicScope() });
  let iteratorResult: IteratorResult<RenderResult>;
  do {
    iteratorResult = templateIterator.next();
  } while (!iteratorResult.done);

  result = iteratorResult.value;
  env.commit();
  assertInvariants(result);
  return result;
}
Example #7
0
    test("The compiler passes along the hash arguments", assert => {
      env.registerHelper('testing', function(params, hash) {
        return hash['first'] + '-' + hash['second'];
      });

      compilesTo('<div>{{testing first="one" second="two"}}</div>', '<div>one-two</div>');
    });
Example #8
0
    test("The compiler can handle sexpr helpers", assert => {
      env.registerHelper('testing', function(params) {
        return params[0] + "!";
      });

      compilesTo('<div>{{testing (testing "hello")}}</div>', '<div>hello!!</div>', {});
    });
Example #9
0
    test("GH#13999 The compiler can handle components with undefined named arguments", assert => {
      env.registerHelper('say-hello', function() {
        return 'hello';
      });

      compilesTo('<div>{{say-hello foo=undefined}}</div>', '<div>hello</div>');
    });
Example #10
0
    test("Attributes can be populated with helpers that generate a string", assert => {
      env.registerHelper('testing', function(params) {
        return params[0];
      });

      compilesTo('<a href="{{testing url}}">linky</a>', '<a href="linky.html">linky</a>', { url: 'linky.html'});
    });