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


TypeScript Parser.on方法代码示例

本文整理汇总了TypeScript中template-lint.Parser.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Parser.on方法的具体用法?TypeScript Parser.on怎么用?TypeScript Parser.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在template-lint.Parser的用法示例。


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

示例1: init

 init(parser: Parser) {
     parser.on("startTag", (name, attrs, selfClosing, location) => {
         this.examineTag(name, attrs, location.line, location.col);
     });
     parser.on("text", (text, location) => {
         this.examineText(text, location.line);
     });
 }
开发者ID:grofit,项目名称:aurelia-template-lint,代码行数:8,代码来源:binding-syntax.ts

示例2: init

    init(parser: Parser) {
        var stack = parser.state.stack

        parser.on("startTag", (tag, attrs, sc, loc) => {
            if (tag == 'slot') {
                var name = "";
                var nameIndex = attrs.findIndex((a) => a.name == "name");

                if (nameIndex >= 0)
                    name = attrs[nameIndex].value;

                this.slots.push({ name: name, loc: loc });

                for (let i = stack.length - 1; i >= 0; i--) {
                    let result = stack[i].attrs.find(x => this.controllers.indexOf(x.name)!= -1)
                    if (result){
                        this.reportIssue(
                            new Issue({
                                message: `slot cannot have ancestor using ${result.name}`,
                                line: loc.line,
                                column: loc.col
                            }));
                        return;
                    }
                }
            }
        })
    }
开发者ID:appleskin,项目名称:aurelia-template-lint,代码行数:28,代码来源:slot.ts

示例3: init

  init(parser: Parser) {
    parser.on("startTag", (tag, attrs, selfClosing, loc) => {
      let rules = this.patterns.filter(r => {
        return r.tag.test(tag);
      });

      if (rules) {
        for (var rule of rules) {
          if (!attrs.find(x => rule.attr.test(x.name))) {
            let issue = new Issue({
              message: rule.msg,
              severity: IssueSeverity.Error,
              line: loc.line,
              column: loc.col,
              start: loc.startOffset,
              end: loc.endOffset
            });
            this.reportIssue(issue);
          }
        }
      }
    });
  }
开发者ID:MeirionHughes,项目名称:aurelia-template-lint,代码行数:23,代码来源:required-attr.ts

示例4: init

    init(parser: Parser) {

        var syntax: RegExp = /(.+)( +of +)(.+)/

        parser.on("startTag", (tag, attrs, selfClosing, loc) => {

            var self = this;

            attrs.forEach(attr => {
                if (attr.name == "repeat") {
                    let issue = new Issue({
                        message: "did you miss `.for` on repeat?", 
                        line: loc.line, 
                        column: loc.col});

                    self.reportIssue(issue);
                    return;
                }
                if (attr.name == "repeat.for") {
                    var script = attr.value.trim();

                    var matches = script.match(syntax);

                    var error = null;

                    if (matches == null || matches.length == 0) {
                        let error = new Issue({
                            message: "repeat syntax should be of form `* of *`",
                            line: loc.line,
                            column: loc.col});
                        self.reportIssue(error);
                    }
                }
            });
        });
    }
开发者ID:grofit,项目名称:aurelia-template-lint,代码行数:36,代码来源:repeatfor.ts

示例5: init

    init(parser: Parser) {
      
        this.disable = false;
        this.first = true;
        this.count = 0;

        parser.on('startTag', (name, attrs, selfClosing, location) => {

            // Ignore Full HTML Documents
            if (this.disable || name == 'html') {
                this.disable = true;
                return;
            }

            if (this.first) {

                if (name != 'template') {
                    let error = new Issue({
                        message: "root element is not template",
                        line: location.line, 
                        column:location.col});
                    
                    this.reportIssue(error);
                    return;
                }
                
                this.count++;
                this.first = false;
                return;
            }

            if (name == 'template') {
                if (this.count > 0) {
                    let stack = parser.state.stack;
                    let stackCount = stack.length;
                    
                    if (stackCount > 0) {

                        this.containers.forEach(containerName => {
                            if(stack[stackCount-1].name == containerName)
                            {
                                let error = new Issue({
                                    message: `template as child of <${containerName}> not allowed`, 
                                    line: location.line, 
                                    column: location.col
                                });

                                this.reportIssue(error);
                            }                     
                        });
                    }
                    else {
                        let error = new Issue({
                            message: "more than one template in file", 
                            line: location.line, 
                            column: location.col});
                        this.reportIssue(error);
                    }
                }
                this.count += 1;
            }
        }); 
    }  
开发者ID:appleskin,项目名称:aurelia-template-lint,代码行数:63,代码来源:template.ts


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