當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript builders.mustache方法代碼示例

本文整理匯總了TypeScript中@glimmer/syntax.builders.mustache方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript builders.mustache方法的具體用法?TypeScript builders.mustache怎麽用?TypeScript builders.mustache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@glimmer/syntax.builders的用法示例。


在下文中一共展示了builders.mustache方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 MustacheStatement: function(node) {
   if (node.path.original === 'x') {
     return b.mustache('y');
   } else if (node.path.original === 'y') {
     return b.mustache('z');
   }
 }
開發者ID:asakusuma,項目名稱:glimmer,代碼行數:7,代碼來源:manipulating-node-test.ts

示例2: traverse

 assert.throws(() => {
   traverse(ast, {
     MustacheStatement: {
       [eventName](node) {
         if (node.path.parts[0] === 'z') {
           return [
             b.mustache('a'),
             b.mustache('b'),
             b.mustache('c')
           ];
         }
       }
     }
   });
 }, cannotReplaceNode(attr.value, attr, 'value'));
開發者ID:asakusuma,項目名稱:glimmer,代碼行數:15,代碼來源:manipulating-node-test.ts

示例3: test

test('BooleanLiteral', assert => {
  const ast = b.program([
    b.mustache('foo', undefined,
      b.hash([b.pair('bar', b.boolean(true))])
    )
  ]);
  assert.equal(print(ast), '{{foo bar=true}}');
});
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:8,代碼來源:print-test.ts

示例4: parse

QUnit.test('Inside of a block', () => {
  let ast = parse(`{{y}}{{#w}}{{x}}{{y}}{{z}}{{/w}}`);

  traverse(ast, {
    MustacheStatement(node) {
      if (node.path.parts[0] === 'y') {
        return [
          b.mustache('a'),
          b.mustache('b'),
          b.mustache('c')
        ];
      }
    }
  });

  astEqual(ast, `{{a}}{{b}}{{c}}{{#w}}{{x}}{{a}}{{b}}{{c}}{{z}}{{/w}}`);
});
開發者ID:asakusuma,項目名稱:glimmer,代碼行數:17,代碼來源:manipulating-node-test.ts

示例5: array

  QUnit.test(`[${eventName}] Replacing self in an array (returning an array with multiple nodes)`, () => {
    let ast = parse(`{{x}}{{y}}{{z}}`);

    traverse(ast, {
      MustacheStatement: {
        [eventName](node) {
          if (node.path.parts[0] === 'y') {
            return [
              b.mustache('a'),
              b.mustache('b'),
              b.mustache('c')
            ];
          }
        }
      }
    });

    astEqual(ast, `{{x}}{{a}}{{b}}{{c}}{{z}}`);
  });
開發者ID:asakusuma,項目名稱:glimmer,代碼行數:19,代碼來源:manipulating-node-test.ts

示例6: key

  QUnit.test(`[${eventName}] Replacing self in a key (returning an array with a single node)`, () => {
    let ast = parse(`<x y={{z}} />`);

    traverse(ast, {
      MustacheStatement: {
        [eventName](node) {
          if (node.path.parts[0] === 'z') {
            return [b.mustache('a')];
          }
        }
      }
    });

    astEqual(ast, `<x y={{a}} />`);
  });
開發者ID:asakusuma,項目名稱:glimmer,代碼行數:15,代碼來源:manipulating-node-test.ts

示例7: key

  QUnit.test(`[${eventName}] Replacing self in a key (returning a node)`, () => {
    let ast = parse(`<x y={{z}} />`);

    traverse(ast, {
      MustacheStatement: {
        [eventName](node: AST.MustacheStatement) {
          if (node.path.type === 'PathExpression' && node.path.parts[0] === 'z') {
            return b.mustache('a');
          }
          return;
        }
      }
    });

    astEqual(ast, `<x y={{a}} />`);
  });
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:16,代碼來源:manipulating-node-test.ts

示例8: array

  QUnit.test(`[${eventName}] Replacing self in an array (returning an array with a single node)`, () => {
    let ast = parse(`{{x}}{{y}}{{z}}`);

    traverse(ast, {
      MustacheStatement: {
        [eventName](node: AST.MustacheStatement) {
          if (node.path.type === 'PathExpression' && node.path.parts[0] === 'y') {
            return [b.mustache('a')];
          }
          return;
        }
      }
    });

    astEqual(ast, `{{x}}{{a}}{{z}}`);
  });
開發者ID:jayphelps,項目名稱:glimmer,代碼行數:16,代碼來源:manipulating-node-test.ts


注:本文中的@glimmer/syntax.builders.mustache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。