当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript runtime.Template类代码示例

本文整理汇总了TypeScript中@glimmer/runtime.Template的典型用法代码示例。如果您正苦于以下问题:TypeScript Template类的具体用法?TypeScript Template怎么用?TypeScript Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Template类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: render

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;
}
开发者ID:jayphelps,项目名称:glimmer,代码行数:13,代码来源:style-warning-test.ts

示例2: UpdatableReference

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;
}
开发者ID:asakusuma,项目名称:glimmer,代码行数:13,代码来源:node-test.ts

示例3: UpdatableReference

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;
}
开发者ID:asakusuma,项目名称:glimmer,代码行数:13,代码来源:debugger-test.ts

示例4: render

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;
}
开发者ID:jayphelps,项目名称:glimmer,代码行数:15,代码来源:attributes-test.ts

示例5: start

export function start() {
  let env = new DemoEnvironment();

  const TEMPLATES = {};

  Array.prototype.slice.call(document.querySelectorAll("[data-template-name]")).forEach(function(node) {
    let name   = node.getAttribute("data-template-name"),
        source = node.textContent;

    TEMPLATES[name] = env.compile(source);
  });

  let data = {
    width:  window.innerWidth,
    height: window.innerHeight,
    points: new RingBuffer(500), // in practice we only have 100-200 circles on screen
    count:  0,
    // fps:    0
  };

  let output = document.getElementById('output');
  let self = new UpdatableReference(data);
  let template: Template<{}> = TEMPLATES['application'];
  let templateIterator = template.render({ self, parentNode: output, dynamicScope: new TestDynamicScope() });

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

  result = result.value;

  window.addEventListener("resize", function() {
    data.width  = window.innerWidth;
    data.height = window.innerHeight;
  });

  document.addEventListener("mousemove", function(e) {
    data.points.push( new Point(window.performance.now(), e.layerX, e.layerY) );
  });

  function tick() {
    let timestamp = window.performance.now();

    data.count = 0;

    data.points.forEach(function(point, i) {
      if (point) {
        point.update(i, timestamp);

        if (point.opacity > 0.001) {
          data.count++;
        } else {
          data.points.remove(i);
        }
      }
    });

    self.update(data);
    env.begin();
    result.rerender();
    env.commit();

    window.requestAnimationFrame(tick);
  }

  tick();
}
开发者ID:jayphelps,项目名称:glimmer,代码行数:68,代码来源:ripples.ts


注:本文中的@glimmer/runtime.Template类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。